3 # Thomas Nagy, 2021 (ita)
5 from waflib
import Utils
, Runner
8 Re-enable the classic threading system from waf 1.x
11 conf.load('classic_runner')
14 class TaskConsumer(Utils
.threading
.Thread
):
16 Task consumers belong to a pool of workers
18 They wait for tasks in the queue and then use ``task.process(...)``
20 def __init__(self
, spawner
):
21 Utils
.threading
.Thread
.__init
__(self
)
23 Obtain :py:class:`waflib.Task.TaskBase` instances from this queue.
25 self
.spawner
= spawner
31 Loop over the tasks to execute
40 Obtain tasks from :py:attr:`waflib.Runner.TaskConsumer.ready` and call
41 :py:meth:`waflib.Task.TaskBase.process`. If the object is a function, execute it.
43 master
= self
.spawner
.master
47 tsk
= master
.ready
.get()
49 tsk
.log_display(tsk
.generator
.bld
)
50 master
.process_task(tsk
)
56 class Spawner(object):
58 Daemon thread that consumes tasks from :py:class:`waflib.Runner.Parallel` producer and
59 spawns a consuming thread :py:class:`waflib.Runner.Consumer` for each
60 :py:class:`waflib.Task.Task` instance.
62 def __init__(self
, master
):
64 """:py:class:`waflib.Runner.Parallel` producer instance"""
66 self
.pool
= [TaskConsumer(self
) for i
in range(master
.numjobs
)]
68 Runner
.Spawner
= Spawner