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 JobListeners 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 TypeMethodDescriptionbooleanAdd a newJobto the worker.voidaddJobListener(JobListener listener) Add aJobListenerto theWorker.voidcancel()Cancel the job processing.booleanhasJobs()Check if there are queued jobs.static Workerinstance()Get (and create on first call) an instance of theWorkerclass.voidremoveJobListener(JobListener listener) Removes aJobListenerfrom theWorker.voidLet the calling thread wait, until the worker finishes processing all jobs.Methods inherited from class de.grogra.video.util.ProgressObservable
setProgressMethods 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 theWorkerclass.- Returns:
- A
Workerinstance
-
addJobListener
Add aJobListenerto theWorker.- Parameters:
listener- -JobListenerto add
-
removeJobListener
Removes aJobListenerfrom theWorker.- Parameters:
listener- -JobListenerto remove
-
addJob
Add a newJobto 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 processedJobis lost.- Throws:
InterruptedException- if theWorkerThreadis interrupted
-