IrisThread

IrisThread — thread abstraction for schedulers

Synopsis

#define             IRIS_TYPE_THREAD
                    IrisThread;
                    IrisThreadWork;
GType               iris_thread_get_type                (void);
IrisThread*         iris_thread_new                     (gboolean exclusive);
IrisThread*         iris_thread_get                     (void);
void                iris_thread_manage                  (IrisThread *thread,
                                                         IrisQueue *queue,
                                                         gboolean leader);
void                iris_thread_shutdown                (IrisThread *thread);
void                iris_thread_print_stat              (IrisThread *thread);
IrisThreadWork*     iris_thread_work_new                (IrisCallback callback,
                                                         gpointer data);
void                iris_thread_work_free               (IrisThreadWork *thread_work);
void                iris_thread_work_run                (IrisThreadWork *thread_work);

Description

IrisThread provides an abstraction upon the underlying threading system for use by IrisScheduler implementations.

Details

IRIS_TYPE_THREAD

#define IRIS_TYPE_THREAD    (iris_thread_get_type())


IrisThread

typedef struct {
	gpointer       user_data;
	gpointer       user_data2;
	gpointer       user_data3;
} IrisThread;


IrisThreadWork

typedef struct {
	IrisCallback callback;
	gpointer     data;
	gboolean     taken;
} IrisThreadWork;


iris_thread_get_type ()

GType               iris_thread_get_type                (void);

Returns :


iris_thread_new ()

IrisThread*         iris_thread_new                     (gboolean exclusive);

Createa a new IrisThread instance that can be used to queue work items to be processed on the thread.

If exclusive, then the thread will not yield to the scheduler and therefore will not participate in scheduler thread balancing.

exclusive :

the thread is exclusive

Returns :

the newly created IrisThread instance

iris_thread_get ()

IrisThread*         iris_thread_get                     (void);

Retrieves the pointer to the current threads structure.

Returns :

the threads structure or NULL if not an IrisThread.

iris_thread_manage ()

void                iris_thread_manage                  (IrisThread *thread,
                                                         IrisQueue *queue,
                                                         gboolean leader);

Sends a message to the thread asking it to retreive work items from the queue.

If leader is TRUE, then the thread will periodically ask the scheduler manager to ask for more threads.

thread :

An IrisThread

queue :

A GAsyncQueue

leader :

If the thread is responsible for asking for more threads

iris_thread_shutdown ()

void                iris_thread_shutdown                (IrisThread *thread);

Sends a message to the thread asking it to shutdown.

thread :

An IrisThread

iris_thread_print_stat ()

void                iris_thread_print_stat              (IrisThread *thread);

Prints the stats of an IrisThread to standard output for analysis. See iris_thread_stat() for programmatically access the statistics.

thread :

An IrisThread

iris_thread_work_new ()

IrisThreadWork*     iris_thread_work_new                (IrisCallback callback,
                                                         gpointer data);

Creates a new instance of IrisThreadWork, which is the negotiated contract between schedulers and the thread workers themselves.

callback :

An IrisCallback

data :

user supplied data

Returns :

The newly created IrisThreadWork instance.

iris_thread_work_free ()

void                iris_thread_work_free               (IrisThreadWork *thread_work);

Frees the resources associated with an IrisThreadWork.

thread_work :

An IrisThreadWork

iris_thread_work_run ()

void                iris_thread_work_run                (IrisThreadWork *thread_work);

Executes the thread work. This method is called from within the worker thread.

thread_work :

An IrisThreadWork