poser
A C framework for POsix SERvices
Loading...
Searching...
No Matches
PSC_ThreadJob Class Reference

A job to be executed on a worker thread. More...

#include <poser/core/threadpool.h>

Public Member Functions

PSC_ThreadJobPSC_ThreadJob_create (PSC_ThreadProc proc, void *arg, int timeoutTicks)
 Create a new thread job.
 
PSC_EventPSC_ThreadJob_finished (PSC_ThreadJob *self)
 The job finished.
 
int PSC_ThreadJob_hasCompleted (const PSC_ThreadJob *self)
 Determine whether the job completed.
 
void PSC_ThreadJob_destroy (PSC_ThreadJob *self)
 PSC_ThreadJob destructor.
 

Static Public Member Functions

int PSC_ThreadJob_canceled (void)
 Check whether a job was canceled.
 

Detailed Description

A job to be executed on a worker thread.

Member Function Documentation

◆ PSC_ThreadJob_canceled()

int PSC_ThreadJob_canceled ( void  )
static

Check whether a job was canceled.

This must only be called from within a PSC_ThreadProc. It signals whether the job was canceled, in that case, the PSC_ThreadProc should exit quickly.

Returns
1 when the job was canceled, 0 otherwise

◆ PSC_ThreadJob_create()

PSC_ThreadJob * PSC_ThreadJob_create ( PSC_ThreadProc  proc,
void *  arg,
int  timeoutTicks 
)

Create a new thread job.

Creates a new job to be executed on a worker thread.

Parameters
procthe function to run on the worker thread
argthe data to work on
timeoutTicksif non-zero, automatically cancel the job after this many PSC_Service_tick() events
Returns
a newly created thread job

◆ PSC_ThreadJob_destroy()

void PSC_ThreadJob_destroy ( PSC_ThreadJob self)

PSC_ThreadJob destructor.

Destroys the thread job.

Note that once the job was scheduled, PSC_ThreadPool will automatically destroy it when it completed or is canceled.

Parameters
selfthe PSC_ThreadJob

◆ PSC_ThreadJob_finished()

PSC_Event * PSC_ThreadJob_finished ( PSC_ThreadJob self)

The job finished.

This event fires when the thread job finished, either because it completed or because it was canceled.

Parameters
selfthe PSC_ThreadJob
Returns
the finished event

◆ PSC_ThreadJob_hasCompleted()

int PSC_ThreadJob_hasCompleted ( const PSC_ThreadJob self)

Determine whether the job completed.

This can be called when PSC_ThreadJob_finished() fired to know whether the job completed successfully.

Parameters
selfthe PSC_ThreadJob
Returns
1 if the job completed, 0 otherwise

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