- Fixed `dipose()` implementation
This commit is contained in:
Tristan B. Velloza Kildaire 2023-06-29 17:18:56 +02:00
parent 0e39b5de31
commit 406023cd6a
1 changed files with 17 additions and 5 deletions

View File

@ -73,7 +73,8 @@ public class Event
* Diposes of this `Event` which
* causes any threads waiting on
* it to unlock and throw an
* exception (TODO: test that),
* exception, prevents any notifying
* or waiting further and
* after this the internal
* resources are relinquished
*/
@ -90,16 +91,24 @@ public class Event
}
/**
* Go through each pipe-pair and close
* one side of it (TODO: closes both)
* therefore closing the pipe
* Go through each mapped pipe-pair
* and close the write-end which
* will cause any blockings reads
* to unblock and return an error
*
* After this close the read-ends
* so we can fully relinquish the
* kernel object associated
*/
foreach(Thread curThread; pipes.keys())
{
/* Extract the pipe-pair */
int[] pipePair = pipes[curThread];
/* Close the one end */
/* Close the write-end */
close(pipePair[1]);
/* Close the read-end */
close(pipePair[0]);
}
}
@ -705,6 +714,9 @@ unittest
// ... for the `wait()` and also is there a way to ensure the fd's are no longer
// ... present?
Thread.sleep(dur!("seconds")(2));
event.dispose();
/* Wait for the thread to exit */