xaya / libxayagame

MIT License
21 stars 19 forks source link

Remove threading from core game-channel code #116

Closed domob1812 closed 2 years ago

domob1812 commented 2 years ago

This set of changes refactors the ChannelManager class (together with a few others around it), so that all threading and synchronisation is removed. Instead, the ChannelManager is now purely logic for handling the various possible updates (e.g. through ProcessOnChain, ProcessOffChain and ProcessLocalMove) and triggering corresponding callbacks (like on-chain transactions or off-chain moves).

All of the actual event loops (for the chain-to-channel feeder or off-chain broadcast receiving) are moved to another level, and synchronisation as well as "wait-for-change" functionality are now in a new class SynchronisedChannelManager.

With this change, the core game-channel logic works without any threading, locks and (in combination with the previous #115) networking. This makes it suitable to be run in other environments, e.g. as wasm in a browser-based frontend.