# Very light-weight cooperative concurrency?

**URL:** <https://discourse.ats-lang.org/t/very-light-weight-cooperative-concurrency/353>\
**Category:** Google Group\
**Created:** [May 3, 2016, 5:02pm UTC](https://discourse.ats-lang.org/t/very-light-weight-cooperative-concurrency/353 "2016-05-03T17:02:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marko\_Schutz-Schmuck](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Marko\_Schutz-Schmuck](https://discourse.ats-lang.org/u/Marko_Schutz-Schmuck)\
**Post date:** [May 3, 2016, 5:02pm UTC](https://discourse.ats-lang.org/t/very-light-weight-cooperative-concurrency/353/1 "2016-05-03T17:02:46Z")

</div>

Looking at Erlang’s actors, Go’s goroutines, Boost coroutines, Protothreads  
and other implementations of cooperative concurrency, I was wondering what  
has been done in this direction in ATS. What I found so far is only  
[https://bluishcoder.co.nz/2012/07/19/lightweight-tasks-library-for-ats.html](https://bluishcoder.co.nz/2012/07/19/lightweight-tasks-library-for-ats.html).  
Since this uses ucontext it is not as light-weight as I was imagining. I  
would assume that this task library could be modified to use  
sigsetjmp/siglongjmp.

What experiences have others made or what approaches have others pursued?

---

<div class="post-metadata">

**Author:** ![Raoul\_Duke](https://avatars.discourse-cdn.com/v4/letter/r/bbe5ce/32.png) [@Raoul\_Duke](https://discourse.ats-lang.org/u/Raoul_Duke)\
**Post date:** [May 3, 2016, 11:20pm UTC](https://discourse.ats-lang.org/t/very-light-weight-cooperative-concurrency/353/2 "2016-05-03T23:20:43Z")

</div>

> atscc2erl

I had no idea. 🙂

---

<div class="post-metadata">

**Author:** ![gmhwxi](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gmhwxi](https://discourse.ats-lang.org/u/gmhwxi)\
**Post date:** [May 3, 2016, 10:30pm UTC](https://discourse.ats-lang.org/t/very-light-weight-cooperative-concurrency/353/3 "2016-05-03T22:30:36Z")

</div>

Not much that I am aware of in this direction.

If you just want to use cooperative threads in ATS, then the simplest way  
is probably  
to make up an interface in ATS for Boost coroutines or protothreads.

Because ATS can be compiled to Erlang via atscc2erl, it makes sense to use  
Erlang’s  
actors as well.

If you know how your application is supposed to use cooperative threads,  
then implementing  
one based on setjmp/longjmp should be pretty quick. And it can be a lot of  
fun as well.

Or, you could try to write your code in the continuation-passing style :)On Tue, May 3, 2016 at 1:02 PM, ‘Marko Schütz-Schmuck’ via ats-lang-users \< [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com)\> wrote:

> Looking at Erlang’s actors, Go’s goroutines, Boost coroutines,  
> Protothreads and other implementations of cooperative concurrency, I was  
> wondering what has been done in this direction in ATS. What I found so far  
> is only  
> [Lightweight Tasks Library for ATS](https://bluishcoder.co.nz/2012/07/19/lightweight-tasks-library-for-ats.html).  
> Since this uses ucontext it is not as light-weight as I was imagining. I  
> would assume that this task library could be modified to use  
> sigsetjmp/siglongjmp.
> 
> What experiences have others made or what approaches have others pursued?
> 
> –  
> You received this message because you are subscribed to the Google Groups  
> “ats-lang-users” group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [ats-lang-user...@googlegroups.com](mailto:ats-lang-user...@googlegroups.com).  
> To post to this group, send email to [ats-lan...@googlegroups.com](mailto:ats-lan...@googlegroups.com).  
> Visit this group at [https://groups.google.com/group/ats-lang-users](https://groups.google.com/group/ats-lang-users).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/ats-lang-users/20a48485-bbdf-47c1-8284-96190488fa0c%40googlegroups.com](https://groups.google.com/d/msgid/ats-lang-users/20a48485-bbdf-47c1-8284-96190488fa0c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/ats-lang-users/20a48485-bbdf-47c1-8284-96190488fa0c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/ats-lang-users/20a48485-bbdf-47c1-8284-96190488fa0c%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .

---

<div class="post-metadata">

**Author:** ![Artyom\_Shalkhakov](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@Artyom\_Shalkhakov](https://discourse.ats-lang.org/u/Artyom_Shalkhakov)\
**Post date:** [May 4, 2016, 4:11pm UTC](https://discourse.ats-lang.org/t/very-light-weight-cooperative-concurrency/353/4 "2016-05-04T16:11:46Z")

</div>

> > atscc2erl
> 
> I had no idea. 🙂

Here’s a good read: [[1603.03727] Session Types in a Linearly Typed Multi-Threaded Lambda-Calculus](http://arxiv.org/abs/1603.03727) (I think HX won’t post  
it out of modesty. :-))
