Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do CSP implementations only cover channels?

In the book about Communicating Sequential Processes a lot of time is spent defining events, which have no direction and can involve multiple independent processes.

Only in chapter 4 are channels introduced, which are directed and involve 2 processes.

Yet all implementations of CSP including occam, Go, LuaCSP and clojure.core.async only implement channels.

Even though most practical problems can be solved with (broadcast) channels, I wonder why the book spends so much time on them while nobody uses them.

like image 668
Pepijn Avatar asked Jul 05 '13 09:07

Pepijn


2 Answers

Well first of all the book happened before the implementations. Therefore your question is better formulated as:

Why does no implementation of CSP put a major focus on events even though the book emphazises them greatly.

Basically, making events a first-class citizen of a language gives it a certain usage specificity that would probably be too narrow for a general purpose programming language.

Additionally, you can easily implement events on channels (and other constructs), in case you are into event driven programming.

like image 122
thwd Avatar answered Oct 28 '22 17:10

thwd


In Occam-pi, barriers are an important adjunct to channels. With a barrier, each enrolled process waits on the barrier until they have all done so. At this point they are all released. This is an example of a non-channel form of CSP event.

Occam-pi also has an extended rendezvous using channels. This is a quite different pattern of usage of channels, very similar to the rendezvous in Ada.

like image 40
Rick-777 Avatar answered Oct 28 '22 18:10

Rick-777