java.lang.Object
java.util.Observable
de.grogra.video.util.ProgressObservable
de.grogra.video.util.Worker
The
Worker
is used to process jobs inside the plugin. Although the
real processing is done inside a corresponding WorkerThread
, the
plugin communicates the the Worker
only. To program lifetime there
can only be one instance of this class, which can be created using the
instance()
method. An arbitrary amount of JobListener
s can
be add to this Worker
. Jobs can be added to the Worker
using
the addJob(Job)
method. To make sure the program doesn't continue
until a job has finished, you can call the waitUntilFinished()
method.- Author:
- Dominick Leppich
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a newJob
to the worker.void
addJobListener
(JobListener listener) Add aJobListener
to theWorker
.void
cancel()
Cancel the job processing.boolean
hasJobs()
Check if there are queued jobs.static Worker
instance()
Get (and create on first call) an instance of theWorker
class.void
removeJobListener
(JobListener listener) Removes aJobListener
from theWorker
.void
Let the calling thread wait, until the worker finishes processing all jobs.Methods inherited from class de.grogra.video.util.ProgressObservable
setProgress
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Method Details
-
instance
Get (and create on first call) an instance of theWorker
class.- Returns:
- A
Worker
instance
-
addJobListener
Add aJobListener
to theWorker
.- Parameters:
listener
- -JobListener
to add
-
removeJobListener
Removes aJobListener
from theWorker
.- Parameters:
listener
- -JobListener
to remove
-
addJob
Add a newJob
to the worker. The job is queued at the end. -
hasJobs
public boolean hasJobs()Check if there are queued jobs.- Returns:
- True, if the worker has queued jobs
-
waitUntilFinished
public void waitUntilFinished()Let the calling thread wait, until the worker finishes processing all jobs. -
cancel
Cancel the job processing. The current processedJob
is lost.- Throws:
InterruptedException
- if theWorkerThread
is interrupted
-