Skip to content

Commit 44d58bc

Browse files
committed
MultiThreadedUnitTestEvaluator: Fixed when using ThreadCount==1
Set all methods inside as Hidden
1 parent a7cdf6e commit 44d58bc

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

test/TensorFlowNET.UnitTest/Utilities/MultiThreadedUnitTestExecuter.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Threading;
34

45
namespace TensorFlowNET.UnitTest
@@ -20,13 +21,15 @@ public class MultiThreadedUnitTestExecuter : IDisposable
2021

2122
#region Static
2223

24+
[DebuggerHidden]
2325
public static void Run(int threadCount, MultiThreadedTestDelegate workload)
2426
{
2527
if (workload == null) throw new ArgumentNullException(nameof(workload));
2628
if (threadCount <= 0) throw new ArgumentOutOfRangeException(nameof(threadCount));
2729
new MultiThreadedUnitTestExecuter(threadCount).Run(workload);
2830
}
2931

32+
[DebuggerHidden]
3033
public static void Run(int threadCount, params MultiThreadedTestDelegate[] workloads)
3134
{
3235
if (workloads == null) throw new ArgumentNullException(nameof(workloads));
@@ -35,6 +38,7 @@ public static void Run(int threadCount, params MultiThreadedTestDelegate[] workl
3538
new MultiThreadedUnitTestExecuter(threadCount).Run(workloads);
3639
}
3740

41+
[DebuggerHidden]
3842
public static void Run(int threadCount, MultiThreadedTestDelegate workload, Action<MultiThreadedUnitTestExecuter> postRun)
3943
{
4044
if (workload == null) throw new ArgumentNullException(nameof(workload));
@@ -58,6 +62,7 @@ public MultiThreadedUnitTestExecuter(int threadCount)
5862
barrier_threadstarted = new SemaphoreSlim(0, threadCount);
5963
}
6064

65+
[DebuggerHidden]
6166
public void Run(params MultiThreadedTestDelegate[] workloads)
6267
{
6368
if (workloads == null)
@@ -67,7 +72,15 @@ public void Run(params MultiThreadedTestDelegate[] workloads)
6772

6873
if (ThreadCount == 1)
6974
{
70-
workloads[0](0);
75+
new Thread(() =>
76+
{
77+
workloads[0](0);
78+
done_barrier2.Release(1);
79+
}).Start();
80+
81+
done_barrier2.Wait();
82+
PostRun?.Invoke(this);
83+
7184
return;
7285
}
7386

0 commit comments

Comments
 (0)