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
6 changes: 5 additions & 1 deletion std/haxe/coro/EventLoop.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package haxe.coro;

#if (target.threaded && !cppia)
import sys.thread.EventLoop;

private typedef EventLoopImpl = sys.thread.EventLoop;
#else
import haxe.coro.EventLoopImpl;
private typedef EventLoopImpl = haxe.coro.EventLoopImpl;
#end

@:coreApi abstract EventLoop(EventLoopImpl) {
public function new() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private class SimpleEventLoop {
}
}

private abstract EventHandler(RegularEvent) from RegularEvent to RegularEvent {}
abstract EventHandler(RegularEvent) from RegularEvent to RegularEvent {}

private class RegularEvent {
public var nextRunTime:Float;
Expand All @@ -205,33 +205,4 @@ private class RegularEvent {
}
}

private typedef EventLoopImpl = SimpleEventLoop;

@:coreApi abstract EventLoop(EventLoopImpl) {
public function new() {
this = new EventLoopImpl();
}

public function tick():Bool {
return switch this.progress() {
case Never:
false;
case _:
true;
}
}

public function run(func:()->Void):Void {
this.run(func);
}

public function runIn(func:()->Void, ms:Int):Void {
var handle : EventHandler = null;

handle = this.repeat(() -> {
this.cancel(handle);

func();
}, ms);
}
}
typedef EventLoopImpl = SimpleEventLoop;
26 changes: 26 additions & 0 deletions std/haxe/coro/continuations/RacingContinuation.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
package haxe.coro.continuations;

#if (target.threaded && !cppia)
import sys.thread.Lock;
import sys.thread.Mutex;
import sys.thread.Thread;
#else
private class Lock {
public function new() {}

public inline function release() {}

public inline function wait(?t:Float) {}
}

private class Mutex {
public function new() {}

public inline function acquire() {}

public inline function release() {}
}

private class Thread {
public static function create(f:Void->Void) {
f();
}
}
#end

@:coreApi class RacingContinuation<T> implements IContinuation<T> {
final _hx_completion:IContinuation<Any>;
Expand Down
47 changes: 0 additions & 47 deletions std/js/_std/haxe/coro/continuations/RacingContinuation.hx

This file was deleted.

Loading