Looking for the name of a pattern

by bebbi   Last Updated May 15, 2019 12:05 PM

Imagine there's a boolean status variable that is either running or stopped.

This variable is running by default and comes together with a deactivator function.

When a client calls the deactivator function, the status changes to stopped.

Calling the deactivator function returns a cancel function, which, when called, reverts the status back to running again.

If multiple clients call the deactivator function, each receives a separate cancel function. As soon as the first client calls the deactivator, the status is stopped and remains so until the last caller to deactivate has called its cancel function.

In other words, every caller can trigger a stopped, and only when no-one is voting stopped, it is running.

What is the name of that pattern?



Related Questions


Updated November 08, 2018 03:05 AM

Updated May 10, 2018 11:05 AM

Updated April 03, 2017 23:05 PM

Updated June 03, 2017 23:05 PM