org.lightwolf
Interface IProcessListener


public interface IProcessListener

A listener for Process events.

Author:
Fernando Colombo
See Also:
Process.addEventListener(IProcessListener)

Field Summary
static int PE_FLOW_ADDED
          A constant indicating that a flow was added to the process.
static int PE_FLOW_REMOVED
          A constant indicating that a flow was removed from the process.
static int PE_FLOW_SUSPENDED
          A constant indicating that a flow was suspended.
static int PE_RESUMING_FLOW
          A constant indicating that a suspended flow is about to be resumed.
 
Method Summary
 void onEvent(Process sender, int event, Flow flow)
          Called when an event happens on a process.
 

Field Detail

PE_FLOW_ADDED

static final int PE_FLOW_ADDED
A constant indicating that a flow was added to the process. Flows can be added to a process using Flow.joinProcess(Process). If a flow that belongs to the process is subject to Flow.fork(int) or Flow.split(int), the new flows are automatically added to the process, triggering this event.

The added flow may be Flow.ACTIVE or Flow.SUSPENDED.

See Also:
Constant Field Values

PE_FLOW_REMOVED

static final int PE_FLOW_REMOVED
A constant indicating that a flow was removed from the process. When a flow finishes normally or by the Flow.end() method, it's removed from its process. Flows can be explicitly removed from a process using Flow.leaveProcess(). If a flow that belongs to the process is subject to Flow.merge(), it's also removed from the process, triggerind this process.

See Also:
Constant Field Values

PE_FLOW_SUSPENDED

static final int PE_FLOW_SUSPENDED
A constant indicating that a flow was suspended. There are many situations that cause a flow to be suspended. The simplest way is the Flow.suspend(Object) method, but some APIs such as Process.receive(Object) may cause a flow to be temporarily suspended.

See Also:
Constant Field Values

PE_RESUMING_FLOW

static final int PE_RESUMING_FLOW
A constant indicating that a suspended flow is about to be resumed. There are many situations that cause a flow to be resumed. For example, if Flow.split(int) is issued on a flow that belongs to a process, new suspended flows are created, then added to the process, and finally they are resumed. Some APIs such as Process.receive(Object) may cause a flow to be temporarily suspended and resumed.

See Also:
Constant Field Values
Method Detail

onEvent

void onEvent(Process sender,
             int event,
             Flow flow)
Called when an event happens on a process. The implementation may query, activate or passivate the process on which the event occurred. Normally this method is implemented to detect when a Process becomes idle, so it can be passivated immediately or in the future.

This method should execute briefly and must not throw an exception. Any thrown exception is simply logged and then ignored. This method is called inside a synchronized block on the informed process, so that Thread.holdsLock(sender) always return true during execution of this method.

Parameters:
sender - The process on which the event happened.
event - The event that happened on the process. See the PE_ constants declared on this interface.
flow - The flow associated with the event. This is the flow being added, removed, suspended or resumed. May be null if the event is not about a flow.