Opened 4 years ago
Closed 3 years ago
#910 closed request (fixed)
add Scheduler API to modify size (number of threads) of the scheduler
Reported by: | Peter | Owned by: | Peter |
---|---|---|---|
Priority: | major | Milestone: | yat 0.17 |
Component: | utility | Version: | |
Keywords: | Cc: |
Description
One use case is that we want to use n threads. We start a Scheduler with n-1 threads and in the main thread, we have pump creating jobs that are sent to the scheduler. When the job creation is completed we call Scheduler::wait which means that we are now only using n-1 threads. It would be useful to increase the scheduler before calling Scheduler::wait
so the scheduler is using n
threads.
An implementation would
- for increasing the size add a thread to the
thread_group worker
and make the new worker act on the queue as its sisters.
- for decreasing these size, we need to send a poison pill to one worker. This means that a poison pill cannot be recursive as it is now, but the job handler should be responsible for feeding the queue with enough pills to kill all workers.
The question is how to communicate the interface in Scheduler to the JobHandler object. It seems the obvious (only) way to communicate between Scheduler and JobHandler? is via the Queue<Job>, which is used for several types of communications, including passing on new jobs, telling the handler to wrap up things, and also for the Worker to tell the Handler that the job has finished. All jobs has a state that pays attention to and handle the jobs differently; it seems we could introduce a new state and/or a new type of job that tells the handler to modify the size of the thread_group
.
Change History (4)
comment:1 Changed 4 years ago by
comment:3 Changed 4 years ago by
Milestone: | yat 0.x+ → yat 0.17 |
---|---|
Owner: | changed from Jari Häkkinen to Peter |
Status: | new → accepted |
Type: | discussion → request |
Ticket #914 was marked related