Skip to content

Commit 7d3a39c

Browse files
author
Pim de Witte
authored
Merge pull request PimDeWitte#4 from aphex-/master
Fixed modifier order.
2 parents be3b15a + 43f34bc commit 7d3a39c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

UnityMainThreadDispatcher.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ limitations under the License.
2020
using System;
2121

2222
/// <summary>
23-
/// 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
23+
/// 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
2424
/// 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
2525
/// </summary>
2626
public class UnityMainThreadDispatcher : MonoBehaviour {
2727

28-
private readonly static Queue<Action> _executionQueue = new Queue<Action>();
28+
private static readonly Queue<Action> _executionQueue = new Queue<Action>();
2929

3030
public void Update() {
3131
lock(_executionQueue) {
@@ -41,12 +41,12 @@ public void Update() {
4141
/// <param name="action">IEnumerator function that will be executed from the main thread.</param>
4242
public void Enqueue(IEnumerator action) {
4343
lock (_executionQueue) {
44-
_executionQueue.Enqueue (() => {
45-
StartCoroutine (action);
44+
_executionQueue.Enqueue (() => {
45+
StartCoroutine (action);
4646
});
4747
}
4848
}
49-
49+
5050
/// <summary>
5151
/// Locks the queue and adds the Action to the queue
5252
/// </summary>
@@ -67,27 +67,25 @@ IEnumerator ActionWrapper(Action a)
6767
public static bool Exists() {
6868
return _instance != null;
6969
}
70-
70+
7171
public static UnityMainThreadDispatcher Instance() {
7272
if (!Exists ()) {
7373
throw new Exception ("UnityMainThreadDispatcher could not find the UnityMainThreadDispatcher object. Please ensure you have added the MainThreadExecutor Prefab to your scene.");
74-
}
74+
}
7575
return _instance;
7676
}
77-
77+
7878

7979
void Awake() {
8080
if (_instance == null) {
8181
_instance = this;
8282
DontDestroyOnLoad(this.gameObject);
83-
}
83+
}
8484
}
8585

8686
void OnDestroy() {
8787
_instance = null;
8888
}
8989

90-
91-
}
92-
9390

91+
}

0 commit comments

Comments
 (0)