The broadcast publish/subscribe pattern (Concurrent programming in the Chemical Machine)

preview_player
Показать описание
I show how to implement the broadcast publish/subscribe pattern in the Chemical Machine, using the Chymyst library.

I derive the code by reasoning about what molecules need to be introduced to implement the desired functionality.

The resulting code is declarative - it is just a few lines of reactions, and these reactions directly describe what the publish/subscribe functionality must do.

The test creates a publisher and two subscribers, and shows that we can subscribe, unsubscribe, and stop the publisher concurrently, at chosen times.

Рекомендации по теме
welcome to shbcf.ru