mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-16 21:08:28 +00:00
make LoadingThread a singleton
This commit is contained in:
parent
857ab69c21
commit
bdd62c1ebd
1 changed files with 3 additions and 9 deletions
|
@ -10,7 +10,7 @@ using Debug = UnityEngine.Debug;
|
|||
namespace SanAndreasUnity.Behaviours
|
||||
{
|
||||
|
||||
public class LoadingThread : MonoBehaviour {
|
||||
public class LoadingThread : StartupSingleton<LoadingThread> {
|
||||
|
||||
// TODO: maybe convert to class, because it takes 36 bytes - it's too much for red-black tree operations
|
||||
public struct Job<T>
|
||||
|
@ -63,8 +63,6 @@ namespace SanAndreasUnity.Behaviours
|
|||
}
|
||||
}
|
||||
|
||||
public static LoadingThread Singleton { get; private set; }
|
||||
|
||||
private Thread _thread;
|
||||
private readonly ThreadParameters _threadParameters = new ThreadParameters();
|
||||
private readonly Queue<Job<object>> _processedJobsBuffer = new Queue<Job<object>>(256);
|
||||
|
@ -77,19 +75,15 @@ namespace SanAndreasUnity.Behaviours
|
|||
public ushort maxTimePerFrameMs = 0;
|
||||
|
||||
|
||||
private void Awake()
|
||||
protected override void OnSingletonStart()
|
||||
{
|
||||
Singleton = this;
|
||||
}
|
||||
|
||||
void Start () {
|
||||
|
||||
_thread = new Thread (ThreadFunction);
|
||||
_thread.Start(_threadParameters);
|
||||
|
||||
}
|
||||
|
||||
void OnDisable ()
|
||||
protected override void OnSingletonDisable()
|
||||
{
|
||||
if (_thread != null)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue