Content deleted Content added
m →libthread channels: proper name tag |
|||
(8 intermediate revisions by 7 users not shown) | |||
Line 2:
In computing, a '''channel''' is a model for [[interprocess communication]] and [[synchronization]] via [[message passing]]. A message may be sent over a channel, and another process or thread is able to receive messages sent over a channel it has a [[reference (computer science)|reference]] to, as a [[stream (computing)|stream]]. Different implementations of channels may be buffered or not, and either synchronous or asynchronous.
== {{Proper name|libthread}} channels ==
Line 13 ⟶ 12:
=== Lua Love2D ===
The [[Löve (game engine)|Love2D]] library which
-- A string containing code which will be interpreted by a function such as loadstring(),
-- but on the C side to start a native thread.
Line 40 ⟶ 39:
=== XMOS XC ===
The [[XMOS]] programming language [[XC (programming language)|XC]] provides a primitive type "
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.
Line 54 ⟶ 53:
=== Go ===
This snippet of [[Go (programming language)|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.<ref>{{Cite web|url=https://golang.org/doc/effective_go.html#channels|title = Effective Go - the Go Programming Language}}</ref>
<syntaxhighlight lang="go">
Line 65 ⟶ 64:
=== Rust ===
[[Rust (programming language)|Rust]] provides asynchronous channels for communication between threads. Channels allow a unidirectional flow of information between two
<syntaxhighlight lang="rust">
Line 87 ⟶ 86:
== List of implementations ==
▲* List of non-standard, library based implementations of channels
* For Scala:
Line 95 ⟶ 93:
* For C++:
** [[stlab]]<ref>{{cite web|url=https://stlab.cc/libraries/concurrency|title=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.|date=2021-01-31}}</ref> This implementation supports splits, and different merge and zip operations. Different executors can be attached to the individual nodes.
* For Rust:
** [[Tokio (software)|Tokio]]
== References ==
|