Network Library Documentation
Loading...
Searching...
No Matches
ThreadsController Class Reference

Implementation of multithreading. More...

Inheritance diagram for ThreadsController:

Static Public Member Functions

static void RefreshMainThread ()
static void StartOnMainThread (Action toBeExecuted)

Private Member Functions

void FixedUpdate ()

Static Private Attributes

static bool executeOnMain = false
static readonly List< Action > mainThreadTasks = new List<Action>()
static readonly List< Action > copiedMainThreadTasks = new List<Action>()

Detailed Description

Implementation of multithreading.

Definition at line 8 of file ThreadsController.cs.

Member Function Documentation

◆ FixedUpdate()

void ThreadsController.FixedUpdate ( )
private

Definition at line 14 of file ThreadsController.cs.

15 {
17 }
static void RefreshMainThread()

◆ RefreshMainThread()

void ThreadsController.RefreshMainThread ( )
static

Definition at line 19 of file ThreadsController.cs.

20 {
21 if(executeOnMain == true)
22 {
24 lock(mainThreadTasks)
25 {
27 mainThreadTasks.Clear();
28 executeOnMain = false;
29 }
30 foreach (Action act in copiedMainThreadTasks)
31 {
32 act();
33 }
34 }
35 }
static readonly List< Action > mainThreadTasks
static readonly List< Action > copiedMainThreadTasks
static bool executeOnMain

◆ StartOnMainThread()

void ThreadsController.StartOnMainThread ( Action toBeExecuted)
static

Definition at line 36 of file ThreadsController.cs.

37 {
38 if(toBeExecuted == null)
39 {
40 return;
41 } else
42 {
43 lock(mainThreadTasks)
44 {
45 mainThreadTasks.Add(toBeExecuted);
46 executeOnMain = true;
47 }
48 }
49 }

Member Data Documentation

◆ copiedMainThreadTasks

readonly List<Action> ThreadsController.copiedMainThreadTasks = new List<Action>()
staticprivate

Definition at line 12 of file ThreadsController.cs.

◆ executeOnMain

bool ThreadsController.executeOnMain = false
staticprivate

Definition at line 10 of file ThreadsController.cs.

◆ mainThreadTasks

readonly List<Action> ThreadsController.mainThreadTasks = new List<Action>()
staticprivate

Definition at line 11 of file ThreadsController.cs.