How to track pipeline stages in OmniThreadLibrary?

Is there any way to control the tasks of the pipeline? I tried adding monitors to every task like this

FPipeline := Parallel.Pipeline() .Stage(StageWorker1, Parallel.TaskConfig.MonitorWith(MyMonitor)) .NumTasks(MaxReadThreadCount) .Stage(StageWorker2, Parallel.TaskConfig.MonitorWith(MyMonitor)) .Run(); 

but getting the exception β€œThe task can be monitored only using one monitor” (as I understand it, this is because the internal hidden monitor is already installed for the pipeline stages).

+4
source share
1 answer

Use Parallel.TaskConfig.OnMessage and provide a generic message processing function.

 FPipeline := Parallel.Pipeline() .Stage(StageWorker1, Parallel.TaskConfig.OnMessage(MessageProc)) .NumTasks(MaxReadThreadCount) .Stage(StageWorker2, Parallel.TaskConfig.OnMessage(MessageProc)) .Run(); procedure MessageProc(var msg: TOmniMessage); begin ... end; 

MessageProc can be a regular procedure or method.

+6
source

Source: https://habr.com/ru/post/1499836/


All Articles