Skip to content

Commit bc5972c

Browse files
committed
refactor: Renamed NetworkProfiler.isRunning to IsRunning
1 parent 3a6a724 commit bc5972c

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

MLAPI-Editor/MLAPIProfiler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private void StopRecording()
7676

7777
private void StartRecording()
7878
{
79-
if (NetworkProfiler.isRunning)
79+
if (NetworkProfiler.IsRunning)
8080
StopRecording();
8181

8282
if (NetworkProfiler.Ticks != null && NetworkProfiler.Ticks.Count >= 2)
@@ -97,15 +97,15 @@ private void ClearDrawing()
9797

9898
private void ChangeRecordState()
9999
{
100-
if (NetworkProfiler.isRunning) StopRecording();
100+
if (NetworkProfiler.IsRunning) StopRecording();
101101
else StartRecording();
102102
}
103103

104104
TickEvent eventHover = null;
105105
double lastSetup = 0;
106106
private void OnGUI()
107107
{
108-
bool recording = NetworkProfiler.isRunning;
108+
bool recording = NetworkProfiler.IsRunning;
109109
float deltaTime = (float)(EditorApplication.timeSinceStartup - lastSetup);
110110
lastSetup = EditorApplication.timeSinceStartup;
111111

@@ -174,7 +174,7 @@ private void OnGUI()
174174
if (prevHis != captureCount) StartRecording();
175175

176176
//Cache
177-
if (NetworkProfiler.isRunning)
177+
if (NetworkProfiler.IsRunning)
178178
{
179179
if (Time.unscaledTime - lastDrawn > updateDelay)
180180
{

MLAPI/Profiling/NetworkProfiler.cs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
24
using MLAPI.Collections;
35
using MLAPI.Configuration;
46
using UnityEngine;
@@ -17,7 +19,14 @@ public static class NetworkProfiler
1719
/// <summary>
1820
/// Whether or not the profiler is recording data
1921
/// </summary>
20-
public static bool isRunning { get; private set; }
22+
[EditorBrowsable(EditorBrowsableState.Never)]
23+
[Obsolete("Use IsRunning instead", false)]
24+
public static bool isRunning => IsRunning;
25+
/// <summary>
26+
/// Whether or not the profiler is recording data
27+
/// </summary>
28+
public static bool IsRunning { get; private set; }
29+
2130
private static int tickHistory = 1024;
2231
private static int EventIdCounter = 0;
2332
private static ProfilerTick CurrentTick;
@@ -28,13 +37,13 @@ public static class NetworkProfiler
2837
/// <param name="historyLength">The amount of ticks to keep in memory</param>
2938
public static void Start(int historyLength)
3039
{
31-
if (isRunning)
40+
if (IsRunning)
3241
return;
3342
EventIdCounter = 0;
3443
Ticks = new FixedQueue<ProfilerTick>(historyLength);
3544
tickHistory = historyLength;
3645
CurrentTick = null;
37-
isRunning = true;
46+
IsRunning = true;
3847
}
3948

4049
/// <summary>
@@ -44,7 +53,7 @@ public static void Stop()
4453
{
4554
Ticks = null; //leave to GC
4655
CurrentTick = null; //leave to GC
47-
isRunning = false;
56+
IsRunning = false;
4857
}
4958

5059
/// <summary>
@@ -54,14 +63,14 @@ public static void Stop()
5463
/// <returns>The number of ticks recorded</returns>
5564
public static int Stop(ref ProfilerTick[] tickBuffer)
5665
{
57-
if (!isRunning)
66+
if (!IsRunning)
5867
return 0;
5968
int iteration = Ticks.Count > tickBuffer.Length ? tickBuffer.Length : Ticks.Count;
6069
for (int i = 0; i < iteration; i++) tickBuffer[i] = Ticks[i];
6170

6271
Ticks = null; //leave to GC
6372
CurrentTick = null; //leave to GC
64-
isRunning = false;
73+
IsRunning = false;
6574

6675
return iteration;
6776
}
@@ -73,21 +82,21 @@ public static int Stop(ref ProfilerTick[] tickBuffer)
7382
/// <returns>The number of ticks recorded</returns>
7483
public static int Stop(ref List<ProfilerTick> tickBuffer)
7584
{
76-
if (!isRunning)
85+
if (!IsRunning)
7786
return 0;
7887
int iteration = Ticks.Count > tickBuffer.Count ? tickBuffer.Count : Ticks.Count;
7988
for (int i = 0; i < iteration; i++) tickBuffer[i] = Ticks[i];
8089

8190
Ticks = null; //leave to GC
8291
CurrentTick = null; //leave to GC
83-
isRunning = false;
92+
IsRunning = false;
8493

8594
return iteration;
8695
}
8796

8897
internal static void StartTick(TickType type)
8998
{
90-
if (!isRunning)
99+
if (!IsRunning)
91100
return;
92101
if (Ticks.Count == tickHistory)
93102
Ticks.Dequeue();
@@ -105,7 +114,7 @@ internal static void StartTick(TickType type)
105114

106115
internal static void EndTick()
107116
{
108-
if (!isRunning)
117+
if (!IsRunning)
109118
return;
110119
if (CurrentTick == null)
111120
return;
@@ -114,7 +123,7 @@ internal static void EndTick()
114123

115124
internal static void StartEvent(TickType eventType, uint bytes, string channelName, byte messageType)
116125
{
117-
if (!isRunning)
126+
if (!IsRunning)
118127
return;
119128
if (CurrentTick == null)
120129
return;
@@ -126,7 +135,7 @@ internal static void StartEvent(TickType eventType, uint bytes, string channelNa
126135

127136
internal static void StartEvent(TickType eventType, uint bytes, string channelName, string messageName)
128137
{
129-
if (!isRunning)
138+
if (!IsRunning)
130139
return;
131140
if (CurrentTick == null)
132141
return;
@@ -136,7 +145,7 @@ internal static void StartEvent(TickType eventType, uint bytes, string channelNa
136145

137146
internal static void EndEvent()
138147
{
139-
if (!isRunning)
148+
if (!IsRunning)
140149
return;
141150
if (CurrentTick == null)
142151
return;

0 commit comments

Comments
 (0)