| Iris Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | ||||
#define IRIS_SCHEDULER_CONST (obj) IrisScheduler; IrisScheduler* iris_scheduler_new (void); IrisScheduler* iris_scheduler_new_full (guint min_threads, guint max_threads); IrisScheduler* iris_scheduler_default (void); gint iris_scheduler_get_min_threads (IrisScheduler *scheduler); gint iris_scheduler_get_max_threads (IrisScheduler *scheduler); void iris_scheduler_queue (IrisScheduler *scheduler, IrisCallback func, gpointer data, GDestroyNotify notify); void iris_scheduler_add_thread (IrisScheduler *scheduler, IrisThread *thread); void iris_scheduler_remove_thread (IrisScheduler *scheduler, IrisThread *thread);
IrisScheduler is a base class used for managing the scheduling of work items onto active threads. The default scheduler is sufficient for most purposes. However, if you need custom scheduling with different queuing decisions you can create your own.
The default scheduler will have a thread per-core with a minimum of 2 threads.
By default, a scheduler will be given "min-threads" threads during startup. If a "leader" thread, (typically the first thread added) feels it is getting behind, it will ask the scheduler manager for more help. The scheduler manager will try to first repurpose existing threads, or create new threads if no existing threads are available. Based on the speed of work performed by the scheduler, the manager will try to appropriate a sufficient number of threads.
IrisScheduler* iris_scheduler_new (void);
Creates a new instance of IrisScheduler with the defaults.
Returns : |
the newly created IrisScheduler instance. |
IrisScheduler* iris_scheduler_new_full (guint min_threads, guint max_threads);
Creates a new scheduler with a defined set of thread ratios.
|
The minimum number of threads to allocate |
|
The maximum number of threads to allocate |
Returns : |
the newly created scheduler instance. |
IrisScheduler* iris_scheduler_default (void);
Retrieves the default scheduler which can be shared.
Returns : |
a IrisScheduler instance |
gint iris_scheduler_get_min_threads (IrisScheduler *scheduler);
Requests the minimum number of threads that the scheduler needs to execute efficiently. This value should never change, and should always be greater or equal to 1.
|
An IrisScheduler |
Returns : |
the minimum number of threads to allocate to the scheduler. |
gint iris_scheduler_get_max_threads (IrisScheduler *scheduler);
Retrieves the maximum number of threads the scheduler should be allocated. The default is equal to the number of cpus unless there is only a single cpu, in which case the default is 2.
Currently, only Linux is supported for the number of cpus. If you
would like another OS supported, please send an email with the method
to retreive the number of cpus (get_nprocs() on Linux).
|
An IrisScheduler |
Returns : |
the maximum number of threads to allocate. |
void iris_scheduler_queue (IrisScheduler *scheduler, IrisCallback func, gpointer data, GDestroyNotify notify);
NOTE: notify will probably disappear soon
Queues a new work item to be executed by one of the schedulers work threads.
|
An IrisScheduler |
|
An IrisCallback |
|
data for func
|
|
an optional callback after execution |
void iris_scheduler_add_thread (IrisScheduler *scheduler, IrisThread *thread);
Requests that the scheduler add the thread to its set of executing
threads. It is the responsibility of the scheduler to tell the thread
to start managing a work queue with iris_thread_manage().
|
An IrisScheduler |
|
An IrisThread |
void iris_scheduler_remove_thread (IrisScheduler *scheduler, IrisThread *thread);
Requests that a scheduler remove the thread from current activity. If the scheduler has a dedicated queue for the thread, it should flush the items into another threads or set of threads queues.
|
An IrisScheduler |
|
An IrisThread |