https://github.com/krgn/fsharp-zmq
A pattern for working with ZeroMQ sockets in Async workflows.
https://github.com/krgn/fsharp-zmq
Last synced: 2 months ago
JSON representation
A pattern for working with ZeroMQ sockets in Async workflows.
- Host: GitHub
- URL: https://github.com/krgn/fsharp-zmq
- Owner: krgn
- Created: 2016-07-27T20:15:53.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-27T21:52:08.000Z (about 10 years ago)
- Last Synced: 2025-03-21T08:21:23.376Z (over 1 year ago)
- Language: F#
- Size: 3.01 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ZeroMQ sockets in FSharp
Using `ZeroMQ` socket in asynchronous computations in `FSharp` can be a daunting task. The reason
behind that is that `ZeroMQ` sockets are explicitly _not_ thread-safe. This is apparently about to
change:
@krstngbbrt there's a new generation of socket types (client, server, radio, dish, scatter, gather) that are threadsafe.
— Pieter Hintjens (@hintjens) July 26, 2016
Until these new, thread-safe socket types land in a proper release and get integrated into the
`.NET` `ZeroMQ` package I need a solution to allow me to pass around and use sockets on different
threads while still guaranteeing that all sockets get closed an disposed of properly.
The demo I cooked up in this repository makes heavy use of `AutoResetEvent` signaling and a single
locking step to synchronize yet another background thread which in turn owns the ZeroMQ socket.
Take a [look at the source to see how its done.](https://github.com/krgn/fsharp-zmq/blob/master/zmq.tests/zmq.tests.fs)
# Usage
Build the thing using `Fake` like this:
```
./build.sh # or .\build.cmd on windows
```
Then start the program in your console and type-in how many random numbers you want to compute the
square of. Thats it.