[Issue 22346] New: TaskPool blocked when execute another task with TaskPool
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 30 03:29:42 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22346
Issue ID: 22346
Summary: TaskPool blocked when execute another task with
TaskPool
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: bitworld at qq.com
OS: Debian 4.9.144-3.1 (2019-02-19) x86_64 GNU/Linux
Compiler: DMD64 D Compiler v2.097.2
Here is the test code:
```d
import std.stdio;
import core.thread;
import core.time;
import std.parallelism;
import std.experimental.logger;
void main() {
testTaskPool();
}
void testTaskPool() {
// enum Total = 15; // It's Ok when Total <= 15
enum Total = 16; // It's blocked by Thread.sleep(dur) when Total >= 16;
for(size_t group = 0; group<Total; group++) {
auto testTask = task(() {
tracef("testing...");
try {
useTaskPool(); // bug test
// useThread(); // It's
always ok
} catch(Exception ex) {
warning(ex);
}
Duration dur = 10.seconds;
infof("Sleeping %s", dur);
Thread.sleep(dur);
infof("awake now");
tracef("testing done");
});
taskPool.put(testTask);
}
warning("press any key to close");
getchar();
}
void useThread() {
Thread th = new Thread(&doSomething);
th.start();
// th.join();
}
void useTaskPool() {
auto testTask = task(&doSomething);
taskPool.put(testTask);
}
```
--
More information about the Digitalmars-d-bugs
mailing list