Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit925c166

Browse files
authored
Fix synchronization in PyScopeTest.TestThread as suggested inda97502 (#1070)
Fixes#1067.
1 parent653a932 commit925c166

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

‎src/embed_tests/TestPyScope.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,16 @@ public void TestThread()
338338
//add function to the scope
339339
//can be call many times, more efficient than ast
340340
ps.Exec(
341-
"importclr\n"+
342-
"from System.Threading import Thread\n"+
341+
"importthreading\n"+
342+
"lock = threading.Lock()\n"+
343343
"def update():\n"+
344-
" global res, th_cnt\n"+
344+
" global res, th_cnt\n"+
345+
" with lock:\n"+
345346
" res += bb + 1\n"+
346-
" Thread.MemoryBarrier()\n"+
347347
" th_cnt += 1\n"
348348
);
349349
}
350-
intth_cnt=3;
350+
intth_cnt=100;
351351
for(inti=0;i<th_cnt;i++)
352352
{
353353
System.Threading.Threadth=newSystem.Threading.Thread(()=>
@@ -368,9 +368,8 @@ public void TestThread()
368368
{
369369
cnt=ps.Get<int>("th_cnt");
370370
}
371-
Thread.Sleep(10);
371+
Thread.Yield();
372372
}
373-
Thread.MemoryBarrier();
374373
using(Py.GIL())
375374
{
376375
varresult=ps.Get<int>("res");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp