mirror of
https://github.com/Pithikos/C-Thread-Pool
synced 2024-11-21 21:21:23 +03:00
Merge pull request #89 from gonzus/gonzus/clean-up-design
Cleaned up design doc
This commit is contained in:
commit
cdcacc8b50
@ -1,47 +1,47 @@
|
|||||||
## High level
|
## High level
|
||||||
|
|
||||||
Description: Library providing a threading pool where you can add work on the fly. The number
|
Description: Library providing a threading pool where you can add work on the fly. The number
|
||||||
of threads in the pool is adjustable when creating the pool. In most cases
|
of threads in the pool is adjustable when creating the pool. In most cases
|
||||||
this should equal the number of threads supported by your cpu.
|
this should equal the number of threads supported by your cpu.
|
||||||
|
|
||||||
For an example on how to use the threadpool, check the main.c file or just read
|
For an example on how to use the threadpool, check the main.c file or just read
|
||||||
the documentation found in the README.md file.
|
the documentation found in the README.md file.
|
||||||
|
|
||||||
In this header file a detailed overview of the functions and the threadpool's logical
|
In this header file a detailed overview of the functions and the threadpool's logical
|
||||||
scheme is presented in case you wish to tweak or alter something.
|
scheme is presented in case you wish to tweak or alter something.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_______________________________________________________
|
_______________________________________________________
|
||||||
/ \
|
/ \
|
||||||
| JOB QUEUE | job1 | job2 | job3 | job4 | .. |
|
| JOB QUEUE | job1 | job2 | job3 | job4 | .. |
|
||||||
| |
|
| |
|
||||||
| threadpool | thread1 | thread2 | .. |
|
| threadpool | thread1 | thread2 | .. |
|
||||||
\_______________________________________________________/
|
\_______________________________________________________/
|
||||||
|
|
||||||
|
|
||||||
Description: Jobs are added to the job queue. Once a thread in the pool
|
Description: Jobs are added to the job queue. Once a thread in the pool
|
||||||
is idle, it is assigned with the first job from the queue(and
|
is idle, it is assigned the first job from the queue (and that job is
|
||||||
erased from the queue). It's each thread's job to read from
|
erased from the queue). It is each thread's job to read from
|
||||||
the queue serially(using lock) and executing each job
|
the queue serially (using lock) and executing each job
|
||||||
until the queue is empty.
|
until the queue is empty.
|
||||||
|
|
||||||
|
|
||||||
Scheme:
|
Scheme:
|
||||||
|
|
||||||
thpool______ jobqueue____ ______
|
thpool______ jobqueue____ ______
|
||||||
| | | | .----------->|_job0_| Newly added job
|
| | | | .----------->|_job0_| Newly added job
|
||||||
| | | rear ----------' |_job1_|
|
| | | rear ----------' |_job1_|
|
||||||
| jobqueue----------------->| | |_job2_|
|
| jobqueue----------------->| | |_job2_|
|
||||||
| | | front ----------. |__..__|
|
| | | front ----------. |__..__|
|
||||||
|___________| |___________| '----------->|_jobn_| Job for thread to take
|
|___________| |___________| '----------->|_jobn_| Job for thread to take
|
||||||
|
|
||||||
|
|
||||||
job0________
|
job0________
|
||||||
| |
|
| |
|
||||||
| function---->
|
| function---->
|
||||||
| |
|
| |
|
||||||
| arg------->
|
| arg------->
|
||||||
| | job1________
|
| | job1________
|
||||||
| next-------------->| |
|
| next-------------->| |
|
||||||
|___________| | |..
|
|___________| | |..
|
||||||
|
Loading…
Reference in New Issue
Block a user