Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
sched.h File Reference
#include <Inventor/C/basic.h>
#include <Inventor/C/threads/common.h>

Go to the source code of this file.

Typedefs

typedef void cc_sched_f(void *closure)
 

Functions

cc_schedcc_sched_construct (int numthreads)
 
void cc_sched_destruct (cc_sched *sched)
 
void cc_sched_set_num_threads (cc_sched *sched, int num)
 
int cc_sched_get_num_threads (cc_sched *sched)
 
uint32_t cc_sched_schedule (cc_sched *sched, cc_sched_f *workfunc, void *closure, float priority)
 
SbBool cc_sched_unschedule (cc_sched *sched, uint32_t schedid)
 
void cc_sched_wait_all (cc_sched *sched)
 
int cc_sched_get_num_remaining (cc_sched *sched)
 
void cc_sched_set_num_allowed (cc_sched *sched, int num)
 
void cc_sched_change_priority (cc_sched *sched, uint32_t schedid, float priority)
 

Typedef Documentation

◆ cc_sched_f

void cc_sched_f

The type definition for the work function called when a thread becomes available.

Function Documentation

◆ cc_sched_construct()

cc_sched* cc_sched_construct ( int  numthreads)

Construct a scheduler that uses numthreads threads.

◆ cc_sched_destruct()

void cc_sched_destruct ( cc_sched sched)

Destruct the scheduler.

This method will block until all currently executing jobs have finished. Any remaining scheduled jobs will be cancelled.

Note that this differs from Coin-2. To emulate Coin-2 behavior, call cc_sched_wait_all() before calling this method.

◆ cc_sched_set_num_threads()

void cc_sched_set_num_threads ( cc_sched sched,
int  num 
)

Set/change the number of threads used by the scheduler.

◆ cc_sched_get_num_threads()

int cc_sched_get_num_threads ( cc_sched sched)

Returns the number of threads used by the scheduler.

◆ cc_sched_schedule()

uint32_t cc_sched_schedule ( cc_sched sched,
cc_sched_f workfunc,
void *  closure,
float  priority 
)

Schedule a new job. A thread calls workfunc with the closure argument when a thread becomes available. larger priority values will be scheduled first.

Returns a schedid that can be used to unschedule the job. schedid is guaranteed to be != 0.

Note that jobs are automatically unscheduled when triggered, just before calling the work function.

◆ cc_sched_unschedule()

SbBool cc_sched_unschedule ( cc_sched sched,
uint32_t  schedid 
)

Attempt to unschedule a job. schedid must be an id returned from cc_sched_schedule().

Note that jobs are automatically unscheduled when triggered, just before calling the work function.

Returns TRUE if job was successfully removed, FALSE if job wasn't found in the internal dict.

◆ cc_sched_wait_all()

void cc_sched_wait_all ( cc_sched sched)

Wait for all scheduled jobs to finish.

◆ cc_sched_get_num_remaining()

int cc_sched_get_num_remaining ( cc_sched sched)

Returns the number of remaining scheduled jobs, not counting jobs that are currently being executed (i.e. are in their workfuncs).

◆ cc_sched_set_num_allowed()

void cc_sched_set_num_allowed ( cc_sched sched,
int  num 
)

Sets the number of allowed jobs per "batch". The scheduler will execute at max the num jobs. To continue executing jobs, call this function again. This is typically done to limit the number of I/O or CPU intensive jobs to a few per frame to avoid starving the main thread.

If num is -1 (the default), the number of jobs per batch is not limited.

◆ cc_sched_change_priority()

void cc_sched_change_priority ( cc_sched sched,
uint32_t  schedid,
float  priority 
)

Changes the priority of the given scheduled item.