The Crystal Programming Language Forum

Thread-safe containers?

Has anyone written thread-safe wrappers for containers?

1 Like

There is a minimal wrapper on GitHub - NeuraLegion/mt_helpers: MultiThreading helpers for crystal that use mutex around some containers.

And a more advanced library to write actors GitHub - NeuraLegion/generic_actor: A generic Actor model for Crystal . This are based on Channel and Fibers so the are lightweight than the previous one.

Those are the ones I know.

1 Like

@BrucePerens as @bcardiff said, we in NeuraLegion use the generic_actor heavily in prod, so I can say it is very battle tested, if you have any question or idea for extension you’re free to suggest\ask or open an issue

I think this is relevant - I wrote this a while ago but tested it with Crystal 1.2 recently.

An Agent is a wrapper that makes it thread-safe to share object references across your application, without having to worry about concurrent access and destructive assignment.