multithreading - F# update list in multiple threads at same time -
i new f# maybe solution can clear someone, can not find it.
imagine game world of world chunks (similar minecraft), more players.
in theory language c++, java, or c# can modify multiple chunks of world @ same time. 2 or more players try place or remove block in different chunks , these actions can change state of world without affecting each other long no more 1 action in each chunk happening. serializing happen when multiple players in 1 chunk perform modification.
my understanding of f# need serialize these actions on global level , no 2 actions can happen in same time in entire world, because update function need actual world state
update params(like add/remove blok)
, return new world state
.
example world state
contains chunk list
.
is there way world update in parallel?
can world state
stored differently allow update multiple chunks @ same time?
it sounds need ensure each chunk has 1 action run @ time. can protect pieces of state storing them inside mailbox processors (often referred "agents"). can send agents several messages several threads. queued , processed 1 @ time.
there detailed discussion of here: https://fsharpforfunandprofit.com/posts/concurrency-actor-model/
Comments
Post a Comment