Shared memory IPC in ATS

71 views
Skip to first unread message

Andrew Knapp

unread,
Apr 9, 2018, 1:11:09 AM4/9/18
to ats-lang-users
Hi all,

I've extracted some ipc code from a larger codebase.

https://github.com/ajknapp/ats-nanomq

It's basically a bunch of SPSC ring buffers in shared memory, and is ported from a C++ library

https://github.com/rigtorp/nanomq

Fair warning: there aren't many scenarios where this design is a good idea, and the code also uses a few more unsafe things than I think would be necessary if I knew ATS better (e.g. the head pointer).

Artyom Shalkhakov

unread,
Apr 9, 2018, 1:23:55 AM4/9/18
to ats-lang-users
Hi Andrew,

Great to see some C-style ATS code in the wild. Definitelly following this development!

Make C great again. :-)

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at 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/68d837ee-dd85-4f25-b24b-016904922bd4%40googlegroups.com.



--
Cheers,
Artyom Shalkhakov

gmhwxi

unread,
Apr 9, 2018, 1:32:31 AM4/9/18
to ats-lang-users

Thanks!

I once tried to use zeromq. For instance, the myserver2 example is
the following directory is based on zeromq:

http://ats-lang.sourceforge.net/EXAMPLE/EFFECTIVATS/http-server/


>>Fair warning: there aren't many scenarios where this design is a good idea

Could you elaborate?

Also, how do you compare zeromq with nanomsg?

Andrew Knapp

unread,
Apr 9, 2018, 1:45:54 AM4/9/18
to ats-lang-users
Nanomq is as bare-bones as you can possibly get. Unlike zeromq, it only works for a small number of local processes, and makes every possible tradeoff for low latency.

Nanomq (in the ATS port and original C++) only offers blocking reads in the public interface (I'll probably change this), which are implemented via spin locks.

Fun fact: nanomq doesn't even use atomics -- with SPSC ring buffers, you can get away with only a compiler fence for reads and a store fence for writes on x86!
Reply all
Reply to author
Forward
0 new messages