5#ifndef FLUTTER_FML_SYNCHRONIZATION_SYNC_SWITCH_H_
6#define FLUTTER_FML_SYNCHRONIZATION_SYNC_SWITCH_H_
12#include "flutter/fml/macros.h"
13#include "flutter/fml/synchronization/shared_mutex.h"
57 void Execute(
const Handlers& handlers)
const;
73 mutable std::unique_ptr<fml::SharedMutex> mutex_;
74 mutable std::vector<Observer*> observers_;
Observes changes to the SyncSwitch.
virtual void OnSyncSwitchUpdate(bool new_is_disabled)=0
virtual ~Observer()=default
void AddObserver(Observer *observer) const
Threadsafe.
SyncSwitch(bool value=false)
void RemoveObserver(Observer *observer) const
Threadsafe.
void Execute(const Handlers &handlers) const
void SetSwitch(bool value)
Dart_NativeFunction function
Represents the 2 code paths available when calling |SyncSwitch::Execute|.
std::function< void()> false_handler
Handlers & SetIfFalse(const std::function< void()> &handler)
Sets the handler that will be executed if the |SyncSwitch| is false.
Handlers & SetIfTrue(const std::function< void()> &handler)
Sets the handler that will be executed if the |SyncSwitch| is true.
std::function< void()> true_handler