File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Threading ;
2
3
using NUnit . Framework ;
3
4
using Python . Runtime ;
4
5
@@ -337,9 +338,12 @@ public void TestThread()
337
338
//add function to the scope
338
339
//can be call many times, more efficient than ast
339
340
ps . Exec (
341
+ "import clr\n " +
342
+ "from System.Threading import Thread\n " +
340
343
"def update():\n " +
341
344
" global res, th_cnt\n " +
342
345
" res += bb + 1\n " +
346
+ " Thread.MemoryBarrier()\n " +
343
347
" th_cnt += 1\n "
344
348
) ;
345
349
}
@@ -364,8 +368,9 @@ public void TestThread()
364
368
{
365
369
cnt = ps . Get < int > ( "th_cnt" ) ;
366
370
}
367
- System . Threading . Thread . Sleep ( 10 ) ;
371
+ Thread . Sleep ( 10 ) ;
368
372
}
373
+ Thread . MemoryBarrier ( ) ;
369
374
using ( Py . GIL ( ) )
370
375
{
371
376
var result = ps . Get < int > ( "res" ) ;
You can’t perform that action at this time.
0 commit comments