How Can I Serialize Access to a Device

That’s pretty much the optimal use-case for the GenServer behavior, you are safe using it.

They block all other processes. By design GenServers can only serve one request at a time (this is how they are able to keep consistent state between requests). call will always block and wait until the caller request was fulfilled (or if it reaches a timeout).

You can check this thread here for more discussion: GenServer use-cases

2 Likes