WorkManager added

A new service called WorkManager has been added. This service should be used to delegate small pieces of work that can be execute asynchronous without creating extra threads yourself.

The reasons for introduction this services are:

  1. Small items of work can now share threads
  2. Now we can track if all work has been done after a startup of JNode

To use this service, call WorkUtils.add(myWork) where myWork is an instance of Work. This is usually an anonymous inner class.

TimerTask

How does this compare with java.util.TimerTask? I assume the WorkManager thread is shared by all processes and executes as a system process, whereas the Timer thread is per Timer object and executes in user process space. Does this imply any security restrictions on the use of WorkManager?

Answer

The timertask runs tasks at a given interval.
The workmanager executes pieces of work in a queued fashion. It does not schedule these tasks at certain intervals (with repeats).

About system processes, jnode does not know about processes, so there is no distinction. I don't know what is going to happen when we implement isolates.
Ewout

Further Question

As WorkManager is a plugin, can it only be stopped once the job queue is empty? If I understand the code correctly, it does not wait for an empty queue before stopping. So, one should not make any assumptions as to whether it will execute any given job. I guess it can only execute on a best-effort basis anyway, since some previous job might never complete. Maybe there should be an isQueued(Work workObject) method so a program can determine whether a given job is still waiting to be executed.