In the last blog post, we learned how Alt in Hopac works and its applications. In this blog post, we are going to apply what we learned so far by creating a Ticker.
Using ticker we can do something repeatedly at regular intervals.
To implement a Ticker in Hopac, we have to know one more abstraction in Hopac called IVar. So, in the first section, we are going to learn IVar and then we’ll use it to implement Ticker.
Welcome back to the fourth part of Concurrent Programming in fsharp blog post series. In part-2, we just learned that Alt<‘a> is a subclass of Job<‘a>. In this blog post, we are doing to dive deep into this abstraction and learn what it brings to the table.
An Example Before diving into the definition of Alt<‘a>, let’s figure out why we need it in the first place.
Assume that we have a function delayedPrintn which prints a given message after n milliseconds
Two years back, I wrote a blog post on how to implement the API Gateway pattern using Reactive Extensions(Rx). In this third part of concurrent programming in fsharp using Hopac blog series, we are going to revisit that blog post and port it to use Hopac instead of Reactive Extensions.
Rx vs Hopac The critical difference between Rx and Hopac is their communication model.
Rx is primarily a system for querying data in motion asynchronously, and systems built using Rx rely on asynchronous message-passing.
In the last blog post, we learned the how to create jobs and run them parallelly using Hopac. In this second part of the blog post series, we are going to explore inter-job communication.
Share Memory By Communicating In multi-threaded programming model, if two threads want to communicate, the typical approach is using a shared memory backed by locks, thread-safe data structures (or other synchronisation primitives). We have to follow specific best practices to avoid Deadlocks and Race Conditions while using the shared memory approach.
Enabling developers to write concise code in solving complex problems is one of the significant characteristics of functional programming. The conciseness is mostly due to the abstractions provided by the functional programming language.
Can we apply these abstractions and write concurrent programs with ease?
We are going to find the answer to this question by writing concurrent programs in fsharp using the Hopac library.
What is Hopac Hopac is a fsharp library that provides a programming model inspired by John Reppy’s Concurrent ML language.