From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.50.50.208 with SMTP id e16mr10496460igo.12.1455915722957; Fri, 19 Feb 2016 13:02:02 -0800 (PST) X-Received: by 10.182.88.134 with SMTP id bg6mr158169obb.3.1455915722939; Fri, 19 Feb 2016 13:02:02 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!hb3no7257139igb.0!news-out.google.com!l1ni18838igd.0!nntp.google.com!hb3no7257131igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 19 Feb 2016 13:02:02 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=78.192.88.225; posting-account=21X1fwoAAABfSGdxRzzAXr3Ux_KE3tHr NNTP-Posting-Host: 78.192.88.225 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Asynchronous channels in Ada From: Hadrien Grasland Injection-Date: Fri, 19 Feb 2016 21:02:02 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:29560 Date: 2016-02-19T13:02:02-08:00 List-Id: Hi everyone, Some months ago, I had some fun learning Go (golang). I found in particular= its concurrency model, based on coroutines and pipe-like communication cha= nnels, to be quite sound and representative of the way I write task-paralle= l programs. Now, to an Ada programmer, coroutines and synchronous channels are not part= icularly special. Coroutines map well to Ada tasks (although most Ada taski= ng implementations are not as CPU- and memory-efficient); and rendezvous an= d protected objects may be considered a more powerful and general alternati= ve to Go-like synchronous channels. On the other hand, asynchronous "buffered" channels are really a neat abstr= action for producer-consumer problems, and I regularly end up facing a prob= lem where I wish I had some in Ada. I'm pretty convinced that one could qui= te easily build a library-based Ada abstraction which offers similar functi= onality, but better. Before trying it myself, though, I'd like to check out= here if you know of an open-source Ada project which has already implement= ed something similar. The ideal intertask communication primitive which I am looking for is... * One-to-one (one-to-many raises plenty of implementation problems, is not = used nearly as often, and may be emulated using one-to-one) * One-way (there are well-separated sender and recipient roles in the commu= nication) * FIFO (objects are received in the same order as they are sent) * Type-safe (all data packets must be of the same type, which should be sel= ectable using a generic formal parameter for optimal abstraction generality= ) * Portable across architectures and Ada compilers * Mostly asynchronous (sender does not block unless buffer is full, recipie= nt does not block unless buffer is empty) * Interruptible (sender and recipient can terminate the communication) * Exception-friendly (sender can notify recipient that an exception has occ= ured) * Blocking-safe (the only circumstance where a task can end up blocking for= ever on a channel is if there is a task on the other end that is permanentl= y blocked too) * Reference-counted (that's really the only sane memory management policy f= or objects which are shared between two unrelated pieces of tasking code) * Devoid of dynamic memory allocation after initialization time (unless the= data packets being transmitted contain controlled dynamically allocated da= ta, of course) Anyone is aware of something like this that would already exist in the wild= ? Cheers, Hadrien