My favorite thing about channels is how they're a universal synchronization primitive. A channel is not just a channel, but also: - a mutex - a semaphore - a wait group - a parker - and a lot more... 1/5
-
-
Semaphore: https://docs.rs/std-semaphore/0.1.0/std_semaphore/struct.Semaphore.html … Make a channel of capacity N that is initially empty. To acquire the semaphore, call send(()). To release the semaphore, call recv(). 3/5
Show this thread -
Wait group: https://golang.org/pkg/sync/#WaitGroup … Make a channel of any capacity that is initially empty. To add an item, make a clone of Sender. To remove an item, drop a Sender. To wait until the wait group is empty, call recv(). 4/5
Show this thread -
Parker: https://doc.rust-lang.org/std/thread/fn.park.html … Make a channel of capacity 1 that is initially empty. To park the current thread, call recv(). To unpark a thread, call try_send(()). 5/5
Show this thread
End of conversation
New conversation -
-
-
make does this for cross process coordination of jobs apparently.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.