You are not logged in.
Hi ab
I have a few scarce resources on the TSynThreadPool that must be correctly shared between the running tasks. Since they are created (slow and cpu intensive to create) when TSynThreadPool is created, I was thinking of putting them in an array and then letting each running task access them according to its position in the running pool. For that, I assume that TSynThreadPoolWorkThread.fThreadNumber must be made public, or does that not contain the task's position in the list of running tasks?
Unfortunately, I can't assign that when the task is pushed onto the queue, because then some of those resources will remain unused while others will be used simultaneously multiple times.
Is there maybe a better way of achieving this? I can create a process whereby each task requests the resource from the pool when running, instead of just getting it from an array, but then I'll have to add so much management and keeping track of the resources, that using the TSynThreadPoolWorkThreads become a bit pointless. There will be only 10 running threads/tasks at the same time, but the Queued tasks may be up to 200.
Offline
It is better not to rely on the TSynThreadPool internals, and rather pass the parameters to the task itself.
It would allow your tasks to be run outside of TSynThreadPool, which may be eventually needed, e.g. for testing, or if you already have a thread available for the process.
Offline