looking for asynchronous flow execution framework

I

ittay.dror

Hi,

I'm looking for a framework that would be able to execute a given code
when actions inside the code are asynchronous.

For example, imagine a software for managing the activities of an
airline company. A code there could look like:

AirplaneLifecycle() {
preFlightMaintanance();

fly();

postFlightMaintanance();
}

all of the above actions trigger physical activities in the external
world, the execution waits, effectively, the thread that handled it
returns. These activities end when an event is sent back to the
framework. This then resumes the execution of the code.

More elaborately, preFlightMaintanance() will, for example, send an SMS
to the chief technician and inform the framwork to wait for the
'pre_flight_maintanance_complete' event. The thread of execution will
finish. When the pre_flight_maintanance_complete event arrives, the
execution will continue where it left off, and call fly() etc.

To me, this sounds very much like what a JVM does. It accepts code and
can stop executing it at any time, continuing later from where it left
off. The difference is that I need specific events to cause the
continuation of the execution. Maybe the framework I'm looking for is
an embedded JVM?

Thanx,
Ittay
 
C

Chris Uppal

I'm looking for a framework that would be able to execute a given code
when actions inside the code are asynchronous.

From your description (snipped) it sounds as if you want to be able to suspend
the state of an executing computation, store it (allowing the thread to go do
something else), and then resume it later, rather than -- say -- just making
the executing thread wait for a long period.

If so then what you are really looking for is "continuations" (for which, see
Google), and Java doesn't do continuations. In fact it /can't/ unless it's
running on a custom JVM, since the standard JVM spec doesn't allow that kind of
manipulation of the execution stack.

For that reason, I doubt if there's any general-purpose framework that will do
just what you want.

I think that you'll have to re-think your architecture to make it more
"event-driven". For instance, your AiroplaneLifecycle object would expose
preFlightMaintanance(), fly(), and postFlightMaintanance(), as top-level
methods that the framework would call in response to external events.
The object could just be stored in a quiescent state (or even serialised and
saved to disk) in between events.

Presumable a general-purpose framework could be built to support that kind of
architecture, and I imagine that such things do exist, but I'm afraid that I
personally don't know of any.

-- chris
 
W

Wibble

We do exactly this in our app, and we rolled our own.
We describe a state machine where incoming messages
drive the system to its next state. Between states,
we passivate to a database. Associated with a state
is a set of 'rules' to execute for each input message type.
 
T

Thomas Schodt

Wibble said:
We do exactly this in our app, and we rolled our own.
We describe a state machine where incoming messages
drive the system to its next state. Between states,
we passivate to a database. Associated with a state
is a set of 'rules' to execute for each input message type.

Yes, a Finite State Machine comes to mind.

We're in the middle of a project that uses
<http://unimod.sourceforge.net/>
for one component.

Our processing is more immediate and continuous
but IIRC all objects in the unimod FSM are serializable
if you want to save the state rather than keep a process running.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top