11using System ;
2+ using System . Diagnostics ;
23using System . Threading ;
34
45namespace 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