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
import core.sync.mutex : Mutex; | |
import core.thread : Thread, Fiber; | |
/** | |
* chan allows messaging between threads without having to deal with locks, similar to how chan works in golang | |
*/ | |
shared | |
class chan(T) { | |
Mutex lock; | |
private bool closed_; bool closed() {synchronized (lock) {return closed_;}} void Close() { synchronized(lock) { closed_ = true; } } |
NewerOlder