Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

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.

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.

About

A pattern for working with ZeroMQ sockets in Async workflows.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages