comp.lang.ada
 help / color / mirror / Atom feed
* Asynchronous channels in Ada
@ 2016-02-19 21:02 Hadrien Grasland
  2016-02-19 21:45 ` Simon Wright
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Hadrien Grasland @ 2016-02-19 21:02 UTC (permalink / raw)


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 channels, to be quite sound and representative of the way I write task-parallel programs.

Now, to an Ada programmer, coroutines and synchronous channels are not particularly special. Coroutines map well to Ada tasks (although most Ada tasking implementations are not as CPU- and memory-efficient); and rendezvous and protected objects may be considered a more powerful and general alternative to Go-like synchronous channels.

On the other hand, asynchronous "buffered" channels are really a neat abstraction for producer-consumer problems, and I regularly end up facing a problem where I wish I had some in Ada. I'm pretty convinced that one could quite easily build a library-based Ada abstraction which offers similar functionality, 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 implemented 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 communication)
* 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 selectable 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, recipient 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 occured)
* Blocking-safe (the only circumstance where a task can end up blocking forever on a channel is if there is a task on the other end that is permanently blocked too)
* Reference-counted (that's really the only sane memory management policy for 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 data, of course)

Anyone is aware of something like this that would already exist in the wild ?

Cheers,
Hadrien

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-03-24  2:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-19 21:02 Asynchronous channels in Ada Hadrien Grasland
2016-02-19 21:45 ` Simon Wright
2016-02-19 23:31   ` Robert A Duff
2016-02-19 21:51 ` Jeffrey R. Carter
2016-02-19 23:53   ` Brad Moore
2016-02-20  9:54 ` Dmitry A. Kazakov
2016-02-21 22:57 ` Hadrien Grasland
2016-02-22  2:30   ` Jeffrey R. Carter
2016-02-22  8:48   ` Dmitry A. Kazakov
2016-02-22  9:28   ` Georg Bauhaus
2016-02-25  7:55 ` Hadrien Grasland
2016-03-24  2:37 ` rieachus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox