Uranium
Application Framework
Loading...
Searching...
No Matches
UM.JobQueue.JobQueue Class Reference

Public Member Functions

None __init__ (self, Union[str, int] thread_count="auto")
None add (self, "Job" job)
None remove (self, "Job" job)
"JobQueue" getInstance (cls, *args, **kwargs)

Static Public Attributes

 jobStarted = Signal()
 jobFinished = Signal()

Protected Member Functions

Optional["Job"] _nextJob (self)

Protected Attributes

list _threads = [_Worker(self, name = "JobQueueWorker [%s]" % t) for t in range(thread_count)]
 _semaphore = threading.Semaphore(0)
list _jobs = []
 _jobs_lock = threading.Lock()

Detailed Description

A thread pool and queue manager for Jobs.

The JobQueue class manages a queue of Job objects and a set of threads that
can take things from this queue to process them.
:sa Job

Constructor & Destructor Documentation

◆ __init__()

None UM.JobQueue.JobQueue.__init__ ( self,
Union[str, int] thread_count = "auto" )
Initialize.

:param thread_count: The amount of threads to use. Can be a positive integer or `auto`.
When `auto`, the number of threads is based on the number of processors and cores on the machine.

Member Function Documentation

◆ _nextJob()

Optional["Job"] UM.JobQueue.JobQueue._nextJob ( self)
protected
protected:

Get the next job off the queue.
Note that this will block until a job is available.

◆ add()

None UM.JobQueue.JobQueue.add ( self,
"Job" job )
Add a Job to the queue.

:param job: The Job to add.

◆ remove()

None UM.JobQueue.JobQueue.remove ( self,
"Job" job )
Remove a waiting Job from the queue.

:param job: The Job to remove.

:note If a job has already begun processing it is already removed from the queue
and thus can no longer be cancelled.

The documentation for this class was generated from the following file:
  • UM/JobQueue.py