Flutter Engine
The Flutter Engine
|
#include <sync_switch.h>
Classes | |
struct | Handlers |
Represents the 2 code paths available when calling |SyncSwitch::Execute|. More... | |
class | Observer |
Observes changes to the SyncSwitch. More... | |
Public Member Functions | |
SyncSwitch (bool value=false) | |
void | Execute (const Handlers &handlers) const |
void | SetSwitch (bool value) |
void | AddObserver (Observer *observer) const |
Threadsafe. More... | |
void | RemoveObserver (Observer *observer) const |
Threadsafe. More... | |
A threadsafe structure that allows you to switch between 2 different execution paths.
Execution and setting the switch is exclusive, i.e. only one will happen at a time.
Definition at line 22 of file sync_switch.h.
|
explicit |
Create a |SyncSwitch| with the specified value.
[in] | value | Default value for the |SyncSwitch|. |
Definition at line 21 of file sync_switch.cc.
void fml::SyncSwitch::AddObserver | ( | Observer * | observer | ) | const |
Threadsafe.
Definition at line 44 of file sync_switch.cc.
void fml::SyncSwitch::Execute | ( | const Handlers & | handlers | ) | const |
Diverge execution between true and false values of the SyncSwitch.
This can be called on any thread. Note that attempting to call |SetSwitch| inside of the handlers will result in a self deadlock.
[in] | handlers | Called for the correct value of the |SyncSwitch|. |
Definition at line 25 of file sync_switch.cc.
void fml::SyncSwitch::RemoveObserver | ( | Observer * | observer | ) | const |
Threadsafe.
Definition at line 52 of file sync_switch.cc.
void fml::SyncSwitch::SetSwitch | ( | bool | value | ) |
Set the value of the SyncSwitch.
This can be called on any thread.
[in] | value | New value for the |SyncSwitch|. |
Definition at line 34 of file sync_switch.cc.