Check for mutex initialization. Fix missing check on optional for certain macro situations.

This commit is contained in:
Christoffer Lerno
2023-08-12 11:54:54 +02:00
parent b6f302d1c6
commit d83f591184
5 changed files with 43 additions and 17 deletions

View File

@@ -5,7 +5,7 @@ fn void! testrun() @test
{
Thread t;
a = 0;
t.create(fn int(void* arg) { a++; return 0; }, null);
t.create(fn int(void* arg) { a++; return 0; }, null)!;
assert(t.join()! == 0);
assert(a == 1);
}
@@ -16,11 +16,11 @@ fn void! testrun_mutex() @test
{
Thread[100] ts;
a = 0;
m.init(thread::MUTEX_PLAIN);
m.init(thread::MUTEX_PLAIN)!;
foreach (&t : ts)
{
t.create(fn int(void* arg) {
m.lock();
m.lock()!!;
defer m.unlock()!!;
a += 10;
thread::sleep_ms(5);
@@ -32,7 +32,7 @@ fn void! testrun_mutex() @test
thread::sleep_ms(5);
a++;
return 0;
}, null);
}, null)!;
}
foreach (i, &t : ts)
{