You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In chat example from Chapter 12, it seems to me that there is no guarantee that when two users kick each other at the same time, only one of the kicks will succeed.
The kick operation is divided to two STM transactions (two atomically calls): one of them is in server function in runClient (at line 214), the second one is in handleMessage (at line 236). When we divide the transaction into two, we lose the atomicity, right?
Here is an example project (https://github.com/shiraeeshi/hs-parconc-chat-server) that shows how to make two concurrent kicks succeed. I added /pause, /resume, /pauseKicks, /resumeKicks commands. You can see the scenario in readme.
The text was updated successfully, but these errors were encountered:
Yes, I think you're right. To fix this, either the two transactions should be combined, or the kick function should check that the current user has not already been kicked.
In chat example from Chapter 12, it seems to me that there is no guarantee that when two users kick each other at the same time, only one of the kicks will succeed.
The kick operation is divided to two STM transactions (two
atomically
calls): one of them is inserver
function inrunClient
(at line 214), the second one is inhandleMessage
(at line 236). When we divide the transaction into two, we lose the atomicity, right?Here is an example project (https://github.com/shiraeeshi/hs-parconc-chat-server) that shows how to make two concurrent kicks succeed. I added
/pause
,/resume
,/pauseKicks
,/resumeKicks
commands. You can see the scenario in readme.The text was updated successfully, but these errors were encountered: