Class SimpleWorker<T>

java.lang.Object
org.oscim.utils.async.SimpleWorker<T>
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
AbstractVectorLayer.Worker

public abstract class SimpleWorker<T> extends Object implements Runnable
Simple 'Double Buffering' worker for running Tasks on AsyncExecutor thread.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected boolean
     
    protected final Map
     
    protected long
     
    protected boolean
     
    protected T
    Stuff that is done an ready for being fetched by poll().
    protected T
    Stuff that is ready - will not be modified in the worker.
    protected T
    Stuff which can be processed on the worker thread.
    protected boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleWorker(Map map, long minDelay, T t1, T t2)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cancel(boolean clear)
     
    abstract void
    cleanup(T task)
     
    abstract boolean
    doWork(T task)
     
    void
     
    boolean
     
    void
    onMainLoop(T task)
    do stuff on main-loop before executing the task
     
    void
    run()
     
    void
    submit(long delay)
    If delay > 0 onMainLoop will be called before Task is passed to worker-thread

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • mMap

      protected final Map mMap
    • mRunning

      protected boolean mRunning
    • mWait

      protected boolean mWait
    • mCancel

      protected boolean mCancel
    • mDelayed

      protected boolean mDelayed
    • mMinDelay

      protected long mMinDelay
    • mTaskTodo

      protected T mTaskTodo
      Stuff which can be processed on the worker thread.
    • mTaskDone

      protected T mTaskDone
      Stuff that is done an ready for being fetched by poll().
    • mTaskLocked

      protected T mTaskLocked
      Stuff that is ready - will not be modified in the worker.
  • Constructor Details

    • SimpleWorker

      public SimpleWorker(Map map, long minDelay, T t1, T t2)
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
    • doWork

      public abstract boolean doWork(T task)
    • cleanup

      public abstract void cleanup(T task)
    • finish

      public void finish()
    • onMainLoop

      public void onMainLoop(T task)
      do stuff on main-loop before executing the task
    • submit

      public void submit(long delay)
      If delay > 0 onMainLoop will be called before Task is passed to worker-thread
    • poll

      public T poll()
    • cancel

      public void cancel(boolean clear)
    • isRunning

      public boolean isRunning()