The multithreading library, libthread, which was first created for the operating system Plan 9, offers inter-thread communication based on fixed-size channels.
The OCaml event module offers typed channels for synchronization. When the module's send and receive functions are called, they create corresponding send and receive events which can be synchronized.
The Love2D library which uses the Lua programming language implements channels with push and pop operations similar to stacks. The pop operation will block so as long as there is data resident on the stack. A demand operation is equivalent to pop, except it will block until there is data on the stack
The XMOS programming language XC provides a primitive type "Chan" and two operators "<:" and ":>" for sending and receiving data from a channel.1
In this example, two hardware threads are started on the XMOS, running the two lines in the "par" block. The first line transmits the number 42 through the channel while the second waits until it is received and sets the value of x. The XC language also allows asynchronous receiving on channels through a select statement.
This snippet of Go code performs similarly to the XC code. First the channel c is created, then a goroutine is spawned which sends 42 through the channel. When the number is put in the channel x is set to 42. Go allows channels to buffer contents, as well as non blocking receiving through the use of a select block.2
Rust provides asynchronous channels for communication between threads. Channels allow a unidirectional flow of information between two endpoints: the Sender and the Receiver.3
In addition to their fundamental use for interprocess communication, channels can be used as a primitive to implement various other concurrent programming constructs which can be realized as streams. For example, channels can be used to construct futures and promises, where a future is a one-element channel, and a promise is a process that sends to the channel, fulfilling the future.4 Similarly, iterators can be constructed directly from channels.5
List of non-standard, library-based implementations of channels
"XMOS Programming Guide | XMOS". Archived from the original on 2016-03-04. Retrieved 2015-05-10. https://web.archive.org/web/20160304132653/https://www.xmos.com/node/17653?version=&page=23 ↩
"Effective Go - the Go Programming Language". https://golang.org/doc/effective_go.html#channels ↩
"Channels - Rust By Example". doc.rust-lang.org. Retrieved 28 November 2020. https://doc.rust-lang.org/rust-by-example/std_misc/channels.html ↩
"Futures Archived 2020-12-04 at the Wayback Machine", Go Language Patterns Archived 2020-11-11 at the Wayback Machine https://sites.google.com/site/gopatterns/concurrency/futures ↩
"Iterators Archived 2020-10-15 at the Wayback Machine", Go Language Patterns Archived 2020-11-11 at the Wayback Machine https://sites.google.com/site/gopatterns/object-oriented/iterators ↩
Sufrin, Bernard (2021-07-13), ThreadCSO (PDF), retrieved 2023-02-17 https://github.com/sufrin/ThreadCSO/blob/5f8ef6eebdfd8e001e45af18fea52fec36ff7ddd/Lectures/cso-paper.pdf ↩
Sufrin, Bernard (2021-07-13), ThreadCSO, retrieved 2023-02-17 https://github.com/sufrin/ThreadCSO ↩
"stlab is the ongoing work of what was Adobe's Software Technology Lab. The Adobe Source Libraries (ASL), Platform Libraries, and new stlab libraries are hosted on github". 2021-01-31. https://stlab.cc/libraries/concurrency ↩