jpool (Job Pool)ο
Header: udo/jpool.h
Table of contents (click to go)ο
Macrosο
Enumsο
Unionsο
Structsο
Functionsο
udo_jpool_sizeof()
API Documentationο
udo_jpool_job (private)ο
Structure defining information about the job to execute.
Is used in
udo_jpool_add_job() to add job a to the jobqueue.
udo_jpool_queue (private)ο
Structure defining information about the job queue.
-
struct udo_jpool_queueο
-
udo_atomic_u32 *job_free;ο
-
udo_atomic_u32 *job_count;ο
-
udo_atomic_u32 *front;ο
-
udo_atomic_u32 *rear;ο
-
void *data;ο
-
uint32_t size;ο
job_free- Futex used to wake threads or put themto sleep if jobs are available.
job_count- Amount of jobs currently in the giventhreads pool.
front- Byte offset to the front of the queue.
rear- Byte offset to the rear of the queue.
data- Starting address caller may store data in.
size- Byte size of queue associated with thread.
-
udo_atomic_u32 *job_free;ο
udo_jpool_thread (private)ο
Structure defining information used by threads.
udo_jpool (private)ο
Structure defining the udo_jpool (Udo Job Pool) context.
-
struct udo_jpoolο
-
struct udo_log_error_struct err;ο
-
bool free;ο
-
uint32_t queue_sz;ο
-
void *queue_data;ο
-
udo_atomic_u32 *cur_thread;ο
-
uint32_t thread_count;ο
-
struct udo_jpool_thread threads[THREADS_MAX];ο
err- Stores information about the error that occuredfor the given context and may later be retrievedby caller.
freequeue_sz- Byte size of
queue_data. queue_data- Shared memory buffer storing actualaddresses to jobs.
cur_thread- Current thread index whose queue will havework placed in it.
thread_count- Amount of threads in the pool.
threads- Array of threads storing location of eachthreads queue and unique ID.
-
struct udo_log_error_struct err;ο
udo_jpool_create_infoο
Structure passed to
udo_jpool_create() usedto define size of shared memory queue and
the amount of threads to create.
-
struct udo_jpool_create_infoο
Creates pool a threads to execute task.
Job Queue (2 threads)ο Variable
Offset In Bytes
Size In Bytes
Initial Value
cur_thread (main process)
0
4
1
Job Free (thread=1)
4
4
0
Front Of Queue (thread=1)
8
4
0
Rear Of Queue (thread=1)
12
4
0
Job Free (thread=2)
16
4
0
Front Of Queue (thread=2)
20
4
0
Rear Of Queue (thread=2)
24
4
0
28
Size of queue
0
End of thread 1 queue
Size of queue
0
Param
Decription
jpool
jpool_info
Implementation uses a pointer to astructudo_jpool_create_info.
- Returns:
on success: Pointer to astructudo_jpoolon failure:NULL
udo_jpool_add_jobο
Adds a job to a given threadβs job queue
to then later execute. If a given threadβs
queue is full function blocks until all
jobs in that queue are completed before
adding a new task.
Param
Decription
jpool
Pointer to a validstructudo_jpool.func
Pointer to function that a separatethread will execute.arg
Pointer to a memory which will bepassed as the argument tofunc.
- Returns:
on success: 0on failure: -1
udo_jpool_waitο
Blocks until all jobs in every
threads queue have been completed.
Param
Decription
jpool
Pointer to a validstructudo_jpool.
udo_jpool_destroyο
Frees any allocated memory and closes FDβs (if open) created after
udo_jpool_create() call. Function waits for all jobs in everythreads queue to execute before destroying the pool.
Param
Decription
jpool
Pointer to a validstructudo_jpool.
udo_jpool_get_sizeofο
-
int udo_jpool_get_sizeof(void);ο
Returns size of the internal structure. So,
if caller decides to allocate memory outside
of API interface they know the exact amount
of bytes.