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

Commit854f20b

Browse files
committed
internally time limit TestThread
1 parentab5b896 commit854f20b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎src/embed_tests/Modules.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,26 +339,35 @@ public void TestThread()
339339
);
340340
}
341341
intth_cnt=100;
342+
intstarted=0,locked=0,unlocked=0;
342343
for(inti=0;i<th_cnt;i++)
343344
{
344345
ThreadPool.QueueUserWorkItem(_=>
345346
{
347+
Interlocked.Increment(refstarted);
346348
using(Py.GIL())
347349
{
350+
Interlocked.Decrement(reflocked);
348351
_ps.update();
349352
}
353+
Interlocked.Increment(refunlocked);
350354
});
351355
}
352356
//equivalent to Thread.Join, make the main thread join the GIL competition
353357
intcnt=0;
354-
while(cnt!=th_cnt)
358+
varstopwatch=System.Diagnostics.Stopwatch.StartNew();
359+
while(cnt!=th_cnt&&stopwatch.ElapsedMilliseconds<15000)
355360
{
356361
using(Py.GIL())
357362
{
358363
cnt=ps.Get<int>("th_cnt");
359364
}
360365
Thread.Yield();
361366
}
367+
368+
if(stopwatch.ElapsedMilliseconds>15000)
369+
Assert.Fail($"started:{started} locked:{locked} unlocked:{unlocked} cnt:{cnt}");
370+
362371
using(Py.GIL())
363372
{
364373
varresult=ps.Get<int>("res");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp