This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Issue 21784: Allow detached threads to be joined
This is useful when a thread terminates before the caller is able to join().
- Loading branch information
1 parent
74287fb
commit c5eb299
Showing
3 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import core.thread; | ||
import core.sync.semaphore; | ||
|
||
__gshared Semaphore sem; | ||
|
||
void thread_main () | ||
{ | ||
sem.notify(); | ||
} | ||
|
||
void main() | ||
{ | ||
auto th = new Thread(&thread_main); | ||
sem = new Semaphore(); | ||
th.start(); | ||
sem.wait(); | ||
while (th.isRunning()) {} | ||
destroy(th); // force detach | ||
th.join(); | ||
} |