Tutorial The Executor Framework (Cyclic & Threaded)

Discussion in 'Tutorials & Resources' started by Ian C, Jul 17, 2014.

  1. Executor Framework
    The Executor Framework is a bilateral, multi-threaded system which provides access to timed and sequential task execution. You have two options when providing tasks to the executor, submit it to the ScheduledExecutorService or add it to the CyclicExecutor. Each one of your tasks must implement the interface Runnable.

    Documentation for my choice of ScheduledExecutorService (ScheduledThreadPoolExecutor): http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html

    I have provided you guys with a simple Task and Transaction framework.


    The Task framework is a simple 2-step task. If the condition returns true, the action will be performed.
    Documentation for the class is available here: http://runemate.com/developer/jdocs/com/runemate/game/api/script/framework/executor/task/Task.html
    If you wish to subclass Task, I'd recommend utilizing AbstractTask. I have already defined the run function so you're only required to write up the condition and action methods.

    The Transaction framework is an object handling system designed to limit the scope of variables when passing from method to method. This eliminates the previously required class variables to pass from condition to action methods when people would use the Task framework. It calls the retrieve function and if the returned value passes isValid, it will call onRetrieval, otherwise onInvalidItem. If your retrieve function is quite intensive, and you want to restrict it to certain conditions, make use of a ConditionalTransaction. This requires condition to return true to begin the normal Transaction process, otherwise calls onDenial.
    Documentation for Transaction is available here: http://runemate.com/developer/jdocs...amework/executor/transaction/Transaction.html

    ExecutorScript example:

    ConditionalTransaction example:

    If you'd like to see anything appended onto this tutorial, feel free to comment. Thanks guys.

    Ian C.​
    #1 Ian C, Jul 17, 2014
    Last edited: Jul 17, 2014
    Arbiter likes this.
  2. Thanks for writing a tutorial on the framework :)
  3. #3 Exile, Aug 22, 2014
    Last edited: Aug 22, 2014
  4. That's an example of using the base executors which is information that you need to understand. Also scheduled executors are executed repeatedly.

Share This Page