Astra Unity 2.6.6
Astra Unity Plugin
Astra.JobQueue Class Reference

This queue is responsible for popping and executing jobs More...

Classes

class  PendingEvent
 
class  WaitForMainJob
 

Public Member Functions

int Push (Job job, bool runImmediatelyIfPossible=false)
 Place a new job into the appropriate queue, returning the id of the job enqueued More...
 
void PrintSizes ()
 Outputs the size of the side thread and main thread queues
 
void RunMainLoop ()
 
IEnumerator RunMainLoopYield ()
 
void Pause ()
 Pause this queue from operating on jobs
 
void Resume ()
 Resume operating on jobs in this queue
 
bool AllThreadsBusy ()
 Reports if the number of jobs started and running exceeds the number of threads This is quite common as jobs will wait for a completion event (they are not blocked though) More...
 
void Clear ()
 Removes all pending jobs from the queue, does NOT abort running jobs
 
void AbortAllJobs ()
 Nukes every job in the queue but keeps the queue running
 
void CancelJobChain (Job job)
 Removes all dependent children from queue Note: does not remove passed in id, it's implied it's already being worked on and popped from the queue More...
 

Public Attributes

bool TrackJobs = false
 Enable this if you want a lot of advanced information about jobs This forces all jobs to print timing and will also scan the job queue periodically to output information
 
float TrackJobsWarnDuration = 5 * 1000
 When tracking jobs, when do we complain about a job that's in the queue
 
int maxEventsPerCycle = 32
 

Protected Member Functions

bool IsJobStateRunnable (Job job)
 I'm leaving this here for historical reference, this will not work the locks are not stable More...
 
bool IsJobRunnable (Job job)
 Tells us if a job has all of it's preconditions met and is able to be executed More...
 
Job Pop ()
 
Job PopB ()
 
bool RunEnqueuedEvents (bool mainThread)
 
void PurgeQueues ()
 
bool RunOne (Job job=null)
 
void OnJobInQueuePostFinally (Job job)
 

Protected Attributes

volatile bool _isPaused = false
 
List< Thread > _threads = new List<Thread>()
 
List< Job_jobs = new List<Job>(100)
 
List< Job_jobsMainThread = new List<Job>(100)
 
List< Job_jobsInc = new List<Job>(100)
 
List< Job_jobsMainThreadInc = new List<Job>(100)
 
bool _hasIncJobs = false
 
Coroutine mainCoroutine = null
 
ManualResetEvent _hasWork = new ManualResetEvent(false)
 
List< Job_jobsRunning = new List<Job>()
 
Dictionary< int, Job_coroutines = new Dictionary<int, Job>()
 
int _sleepDuration = 5
 
int _maxShutdownTime = 1000
 
float _maxDurationOnMainThread = 10
 
int _maxJobHistoryDuration = 120
 
volatile bool _isShutdown = false
 
int _lastFrameCount = -1
 
System.Diagnostics.Stopwatch _swMainThreadTimer = new System.Diagnostics.Stopwatch()
 
System.Diagnostics.Stopwatch _swAdvance = new System.Diagnostics.Stopwatch()
 
float _maxCycles = 100f
 

Static Protected Attributes

static System.Object _lockCoroutines = new System.Object()
 

Properties

bool IsPaused [get]
 Whether the queue is currently paused
 
int Count [get]
 Gets a non-safe count of the jobs (this will not lock and may not always be accurate) More...
 
int CountMain [get]
 
int CountSide [get]
 
float MaxDurationOnMainThread [getset]
 How long in ms that jobs are allowed to run per frame. Default is 10. Set higher when it is more important to process jobs than it is to maintain framerate, such as during loading.
 

Detailed Description

This queue is responsible for popping and executing jobs

Member Function Documentation

◆ AllThreadsBusy()

bool Astra.JobQueue.AllThreadsBusy ( )
inline

Reports if the number of jobs started and running exceeds the number of threads This is quite common as jobs will wait for a completion event (they are not blocked though)

Returns

◆ CancelJobChain()

void Astra.JobQueue.CancelJobChain ( Job  job)
inline

Removes all dependent children from queue Note: does not remove passed in id, it's implied it's already being worked on and popped from the queue

Parameters
jobJob to be cancelled

◆ IsJobRunnable()

bool Astra.JobQueue.IsJobRunnable ( Job  job)
inlineprotected

Tells us if a job has all of it's preconditions met and is able to be executed

Parameters
job
Returns
True if we can run it, false if not

◆ IsJobStateRunnable()

bool Astra.JobQueue.IsJobStateRunnable ( Job  job)
inlineprotected

I'm leaving this here for historical reference, this will not work the locks are not stable

Returns

◆ OnJobInQueuePostFinally()

void Astra.JobQueue.OnJobInQueuePostFinally ( Job  job)
inlineprotected

Fired internally when a job is done

◆ PopB()

Job Astra.JobQueue.PopB ( )
inlineprotected

Used internally to get the next job off the queue

Returns
The next job or null if no jobs to process

◆ Push()

int Astra.JobQueue.Push ( Job  job,
bool  runImmediatelyIfPossible = false 
)
inline

Place a new job into the appropriate queue, returning the id of the job enqueued

Parameters
jobJob to be queued
callbackOptional callback which is called when the job is complete

◆ RunEnqueuedEvents()

bool Astra.JobQueue.RunEnqueuedEvents ( bool  mainThread)
inlineprotected

Runs pending events based on the queue

Returns
True if there are still events, false otherwise

◆ RunOne()

bool Astra.JobQueue.RunOne ( Job  job = null)
inlineprotected

Processes a single job

Returns
true if a job was processed, false if none found

Member Data Documentation

◆ _swAdvance

System.Diagnostics.Stopwatch Astra.JobQueue._swAdvance = new System.Diagnostics.Stopwatch()
protected

Used in editor non-play mode to make coroutines work

Property Documentation

◆ Count

int Astra.JobQueue.Count
get

Gets a non-safe count of the jobs (this will not lock and may not always be accurate)


The documentation for this class was generated from the following file: