Commit graph

21 commits

Author SHA1 Message Date
Sönke Ludwig ade765d6bd Fix a worker task scheduling issue for busy worker tasks.
Fixes new tasks being able to be scheduled on a worker thread while a busy task (that periodically calls yield()) is running.
2020-12-15 19:43:20 +01:00
Geod24 bd8c2c6e90 Use logException consistently and use logDiagnostic
Many places around were re-inventing logException with varying level of success.
In addition, the full error is now printed as a diagnostic instead of debug.
This is more in line with the description of `LogLevel.diagnostic`
("Extended user information (e.g. for more detailed error information)"),
as opposed to the one of `LogLevel.debug_`
("Developer information useful for algorithm debugging").
2020-08-24 05:17:59 +02:00
Sönke Ludwig 262b417794 Add TaskSettings overloads for runWorkerTaskDist(H). 2020-03-14 23:33:41 +01:00
Sönke Ludwig 6a2dfa468b Implement priority based task scheduling.
1. Removes the marker task used by schedule() and instead limits the number of task resumptions to the initial length of the task queue
2. Assigns a static and a dynamic priority to each task. The dynamic priority starts with the same value as the static priority and gets incremented by the static priority each time the task gets overtaken by a higher priority task, eventually leading to the task becoming the highest priority (unless the static priority is zero). Tasks with a higher dynamic priority generally take precedence, unless the concurrency exceeds 10 scheduled tasks, in which case the front of the queue is scheduled in normal FIFO order.
2020-03-14 20:37:33 +01:00
Sönke Ludwig 8e24c4a204 Correct copyright holder.
rejectedsoftware e.K. doesn't exist anymore since mid-2019.
2020-01-27 19:20:52 +01:00
Sönke Ludwig 81ba969fd6 Reduce log noise for worker tasks. 2019-10-22 11:30:31 +02:00
Sönke Ludwig 5640516ba8 Remove SpinLock and use core.sync.mutex.Mutex instead.
The places that used it showed too much contention in load tests, so that the spin lock was more expensive that the regular OS mutex/futex.
2019-09-19 11:25:14 +02:00
Sönke Ludwig 4f5636dadf Mark async/Future and runWorkerTaskH as safe. 2019-08-21 13:34:00 +02:00
Sönke Ludwig a54fa6b7de Implement runWorkerTaskDistH.
Variant of runWorkerTask that allows to get the handles of the created tasks.
2019-01-26 18:02:47 +01:00
Sönke Ludwig dfd7d97225 Fix parameter documentation syntax. Fixes #103. 2019-01-14 10:22:13 +01:00
Sönke Ludwig 6caff0b105 Fix synchronization and shutdown issues in TaskPool.
- terminate() would hang if called from a worker thread because it would attempt to self-join
- the handleWorkerTasks could miss signal emits, resulting in a hanging task queue or a missed termination signal
2018-10-27 00:42:06 +02:00
Sönke Ludwig 849bca4855 Avoid starting an explicit event loop in worker threads.
This reduces the overhead of task pool threads slightly and simplifies stack traces in case of errors.
2018-10-23 11:27:28 +02:00
Sönke Ludwig 7703cc675f Fix a race-condition in TaskPool.
The lock that should surround the foreach loop was given up prematurely.
2018-03-07 10:39:28 +01:00
Sönke Ludwig 0dbebac482 Add TaskPool.threadCount property. 2017-09-21 13:38:24 +02:00
Sönke Ludwig a60828d6da Mark more classes as final. 2017-07-23 15:04:11 +02:00
Sönke Ludwig bfc6b89ca4
Use abort() in case of uncaught Error exceptions.
Fixes "dwarfeh(224) fatal error" that are suspected to be related to occasional infinite loops.
2017-07-19 00:11:12 +02:00
Sönke Ludwig 0895cd1960
Avoid bogus assertion failure.
Since the task queue entries never got cleaned up, the assertion got triggered once already used queue slots were starting to get reused.
2017-03-27 16:31:52 +02:00
Sönke Ludwig b995bdaa72
Use thread wait primitives for worker thread shutdown.
Avoids possible issues due to tasks interleaving the shutdown on the same thread.
2017-02-23 14:43:22 +01:00
Sönke Ludwig 76882b3bd7 Remove temporary debug log messages. 2017-02-22 19:58:11 +01:00
Sönke Ludwig 9ac908c599 Use a ring buffer for worker tasks and make TaskFuncInfo creation slightly more efficient. 2017-02-22 19:52:22 +01:00
Sönke Ludwig 40713db075 Move worker task logic into a new TaskPool class. 2017-02-22 18:35:51 +01:00