Haply::Inverse::Unity::EventDispatcher
A thread-safe class which holds a queue with actions to execute on the next Update method. More...
Inherits from Haply.Inverse.Unity.Utilities.Singleton< EventDispatcher >, MonoBehaviour
Public Functions
Name | |
---|---|
void | Enqueue(IEnumerator action) Locks the queue and adds the IEnumerator to the queue. |
void | Enqueue(Action action) Locks the queue and adds the Action to the queue. |
void | Enqueue(UnityEvent action) Locks the queue and adds the Action to the queue. |
void | Enqueue< T >(Action< T > action, T arg) Locks the queue and adds the Action (with a parameter T) to the queue. |
void | Enqueue< T >(UnityEvent< T > action, T arg) Locks the queue and adds the Action (with a parameter T) to the queue. |
void | Enqueue< T0, T1 >(Action< T0, T1 > action, T0 arg0, T1 arg1) Locks the queue and adds the Action (with two parameters T0 and T1) to the queue. |
void | Enqueue< T0, T1 >(UnityEvent< T0, T1 > action, T0 arg0, T1 arg1) Locks the queue and adds the UnityEvent (with two parameters T0 and T1) to the queue. |
void | Enqueue< T0, T1, T2 >(Action< T0, T1, T2 > action, T0 arg0, T1 arg1, T2 arg2) Locks the queue and adds the Action (with tree parameters T0, T1 and T2) to the queue. |
void | Enqueue< T0, T1, T2 >(UnityEvent< T0, T1, T2 > action, T0 arg0, T1 arg1, T2 arg2) Locks the queue and adds the UnityEvent (with tree parameters T0, T1 and T2) to the queue. |
Task | EnqueueAsync(Action action) Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes. |
Task | EnqueueAsync(UnityEvent action) Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes. |
Task | EnqueueAsync< T >(Action< T > action, T arg) Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes. |
Task | EnqueueAsync< T >(UnityEvent< T > action, T arg) Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes. |
Protected Functions
Name | |
---|---|
virtual override void | Awake() |
virtual override void | Update() |
Public Properties
Name | |
---|---|
bool | IsMainThread |
Additional inherited members
Public Functions inherited from Haply.Inverse.Unity.Utilities.Singleton< EventDispatcher >
Name | |
---|---|
bool | Exists() |
Protected Functions inherited from Haply.Inverse.Unity.Utilities.Singleton< EventDispatcher >
Name | |
---|---|
virtual void | OnEnable() |
virtual void | OnDisable() |
virtual void | OnDestroy() |
virtual void | OnApplicationQuit() |
Public Properties inherited from Haply.Inverse.Unity.Utilities.Singleton< EventDispatcher >
Name | |
---|---|
T | Instance Gets the instance of the singleton class. |
Detailed Description
class Haply::Inverse::Unity::EventDispatcher;
A thread-safe class which holds a queue with actions to execute on the next Update method.
It can be used to make calls to the main thread for things such as UI Manipulation in Unity. It was developed for use in combination with the Firebase Unity plugin, which uses separate threads for event handling
Author: Pim de Witte (pimdewitte.com) and contributors, https://github.com/PimDeWitte/UnityMainThreadDispatcher
Public Functions Documentation
function Enqueue
void Enqueue(
IEnumerator action
)
Locks the queue and adds the IEnumerator to the queue.
Parameters:
- action IEnumerator function that will be executed from the main thread.
function Enqueue
void Enqueue(
Action action
)
Locks the queue and adds the Action to the queue.
Parameters:
- action function that will be executed from the main thread.
function Enqueue
void Enqueue(
UnityEvent action
)
Locks the queue and adds the Action to the queue.
Parameters:
- action function that will be executed from the main thread.
function Enqueue< T >
void Enqueue< T >(
Action< T > action,
T arg
)
Locks the queue and adds the Action (with a parameter T) to the queue.
Parameters:
- action function (requires parameter of type T) that will be executed from the main thread.
- arg parameter of type T to pass to action.
Template Parameters:
- T The type of the parameter for the action.
function Enqueue< T >
void Enqueue< T >(
UnityEvent< T > action,
T arg
)
Locks the queue and adds the Action (with a parameter T) to the queue.
Parameters:
- action function (requires parameter of type T) that will be executed from the main thread.
- arg parameter of type T to pass to action.
Template Parameters:
- T The type of the parameter for the action.
function Enqueue< T0, T1 >
void Enqueue< T0, T1 >(
Action< T0, T1 > action,
T0 arg0,
T1 arg1
)
Locks the queue and adds the Action (with two parameters T0 and T1) to the queue.
Parameters:
- action function (requires parameters of type T0 and T1) that will be executed from the main thread.
- arg0 parameter of type T0 to pass to action.
- arg1 parameter of type T1 to pass to action.
Template Parameters:
- T0 The type of the first parameter for the action.
- T1 The type of the second parameter for the action.
function Enqueue< T0, T1 >
void Enqueue< T0, T1 >(
UnityEvent< T0, T1 > action,
T0 arg0,
T1 arg1
)
Locks the queue and adds the UnityEvent (with two parameters T0 and T1) to the queue.
Parameters:
- action function (requires parameters of type T0 and T1) that will be executed from the main thread.
- arg0 parameter of type T0 to pass to action.
- arg1 parameter of type T1 to pass to action.
Template Parameters:
- T0 The type of the first parameter for the action.
- T1 The type of the second parameter for the action.
function Enqueue< T0, T1, T2 >
void Enqueue< T0, T1, T2 >(
Action< T0, T1, T2 > action,
T0 arg0,
T1 arg1,
T2 arg2
)
Locks the queue and adds the Action (with tree parameters T0, T1 and T2) to the queue.
Parameters:
- action function (requires parameters of type T0, T1 and T2) that will be executed from the main thread.
- arg0 parameter of type T0 to pass to action.
- arg1 parameter of type T1 to pass to action.
- arg2 parameter of type T2 to pass to action.
Template Parameters:
- T0 The type of the first parameter for the action.
- T1 The type of the second parameter for the action.
- T2 The type of the third parameter for the action.
function Enqueue< T0, T1, T2 >
void Enqueue< T0, T1, T2 >(
UnityEvent< T0, T1, T2 > action,
T0 arg0,
T1 arg1,
T2 arg2
)
Locks the queue and adds the UnityEvent (with tree parameters T0, T1 and T2) to the queue.
Parameters:
- action function (requires parameters of type T0, T1 and T2) that will be executed from the main thread.
- arg0 parameter of type T0 to pass to action.
- arg1 parameter of type T1 to pass to action.
- arg2 parameter of type T2 to pass to action.
Template Parameters:
- T0 The type of the first parameter for the action.
- T1 The type of the second parameter for the action.
- T2 The type of the third parameter for the action.
function EnqueueAsync
Task EnqueueAsync(
Action action
)
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
Parameters:
- action function that will be executed from the main thread.
Return: A Task that can be awaited until the action completes
function EnqueueAsync
Task EnqueueAsync(
UnityEvent action
)
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
Parameters:
- action function that will be executed from the main thread.
Return: A Task that can be awaited until the action completes
function EnqueueAsync< T >
Task EnqueueAsync< T >(
Action< T > action,
T arg
)
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
Parameters:
- action function that will be executed from the main thread.
- arg parameter of type T to pass to action.
Template Parameters:
- T The type of the parameter for the action.
Return: A Task that can be awaited until the action completes
function EnqueueAsync< T >
Task EnqueueAsync< T >(
UnityEvent< T > action,
T arg
)
Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes.
Parameters:
- action function that will be executed from the main thread.
- arg parameter of type T to pass to action.
Template Parameters:
- T The type of the parameter for the action.
Return: A Task that can be awaited until the action completes
Protected Functions Documentation
function Awake
virtual override void Awake()
Reimplements: Haply::Inverse::Unity::Utilities::Singleton::Awake
function Update
virtual override void Update()
Reimplements: Haply::Inverse::Unity::Utilities::Singleton::Update
Public Property Documentation
property IsMainThread
static bool IsMainThread;