com.neeve.emx
Class EmxActionExecutor<E,V>
java.lang.Object
com.neeve.root.RootObject
com.neeve.emx.EmxObject
com.neeve.emx.EmxActionExecutor<E,V>
public final class EmxActionExecutor<E,V>
- extends EmxObject
Executes actions in a dispatcher owner thread.
There are many cases when a user needs an action to be performed by the
owner thread of the dispatcher where the current thread may or may not
be the owner thread. To handle this case, the calling thread first compares
itself against the dispatcher owner thread. If it is the same, it executes
the action immediately. Otherwise, it posts a user event to the dispatcher
and the action is performed from the user event handler. In case the action
needs to be performed synchronously i.e. the calling thread cannot return
until the action is complete, then the calling thread needs to block and
wait until the dispatcher owner thread completes the action. This class
abstracts this process.
- Threading:
- This class is safe for concurrent access by multiple threads.
FLG_SYNC
public static final int FLG_SYNC
- Indicates that the thread calling
invoke(com.neeve.emx.IEmxDispatcher, com.neeve.emx.IEmxAction, E, int)
should not wait for the action to complete before returning. In this
case, the thread will return immediately from the invoke method. The
action execution status will be discarded in case this flag is specified.
- See Also:
- Constant Field Values
EmxActionExecutor
public EmxActionExecutor()
- Constructor
invoke
public final V invoke(IEmxDispatcher dispatcher,
IEmxAction<E,V> action,
E object,
int flags)
throws Exception
- Executes an action.
- Parameters:
dispatcher
- The dispatcher in whose context the action needs to
be executes.action
- the action to execute.object
- An opaque object that is passed to the action execute
method.flags
- A set of flags used to qualify the operation of this method.
- Throws:
Exception
- Thrown if any exception occurs while invoking the
action or by the action itself.
This method executes an action. It takes a dispatcher, an action, an
opaque object and a set of flags as parameters. It first compares the
calling thread against the dispatcher owner thread. If same, it either
invokes the action immediately. If the calling thread is different from
the dispatcher owner, it posts a user event to the dispatcher and either
waits and immediately returns depending on the the flags specified. The
dispatcher event handler invokes the action and returns any object or
exception thrown by the action to the waiting thread (if any). The
waiting thread returns the object or throws the exception returned by
the action.
- Threading:
- This method is safe for concurrent access by multiple threads.
Copyright © 2015 Neeve Research, LLC. All Rights Reserved.