Channel (programming): Difference between revisions

Content deleted Content added
 
(5 intermediate revisions by 5 users not shown)
Line 39:
 
=== XMOS XC ===
The [[XMOS]] programming language [[XC (programming language)|XC]] provides a primitive type "chanChan" and two operators "<:" and ":>" for sending and receiving data from a channel.<ref>{{Cite web |url=https://www.xmos.com/node/17653?version=&page=23 |title=XMOS Programming Guide &#124; XMOS |access-date=2015-05-10 |archive-url=https://web.archive.org/web/20160304132653/https://www.xmos.com/node/17653?version=&page=23 |archive-date=2016-03-04 |url-status=dead }}</ref>
 
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 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 64:
 
=== Rust ===
[[Rust (programming language)|Rust]] provides asynchronous channels for communication between threads. Channels allow a unidirectional flow of information between two end-pointsendpoints: the <code>Sender</code> and the <code>Receiver</code>.<ref>{{cite web |title=Channels - Rust By Example |url=https://doc.rust-lang.org/rust-by-example/std_misc/channels.html |website=doc.rust-lang.org |access-date=28 November 2020}}</ref>
 
<syntaxhighlight lang="rust">
Line 86:
 
== List of implementations ==
* List of non-standard, library -based implementations of channels
 
* List of non-standard, library based implementations of channels
 
* For Scala:
Line 94 ⟶ 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 ==