Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions std/neko/_std/sys/thread/Condition.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package sys.thread;

class Condition {
var c:Dynamic;

public function new():Void {
c = cond_create();
}

public function acquire():Void {
cond_acquire(c);
}

public function tryAcquire():Bool {
return cond_try_acquire(c);
}

public function release():Void {
cond_release(c);
}

public function wait():Void {
cond_wait(c);
}

public function signal():Void {
cond_signal(c);
}

public function broadcast():Void {
cond_broadcast(c);
}

static var cond_create = neko.Lib.loadLazy("std", "cond_create", 0);
static var cond_try_acquire = neko.Lib.loadLazy("std", "cond_try_acquire", 1);
static var cond_acquire = neko.Lib.loadLazy("std", "cond_acquire", 1);
static var cond_release = neko.Lib.loadLazy("std", "cond_release", 1);
static var cond_wait = neko.Lib.loadLazy("std", "cond_wait", 1);
static var cond_signal = neko.Lib.loadLazy("std", "cond_signal", 1);
static var cond_broadcast = neko.Lib.loadLazy("std", "cond_broadcast", 1);
}
4 changes: 0 additions & 4 deletions tests/threads/src/cases/TestCondition.hx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package cases;

#if !neko
import sys.thread.Condition;
import sys.thread.Thread;
#end

class TestCondition extends utest.Test {
#if !neko
function test() {
final cond = new Condition();
cond.acquire();
Expand All @@ -19,5 +16,4 @@ class TestCondition extends utest.Test {
cond.release();
utest.Assert.pass();
}
#end
}