-
-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MainLoop hangs with concurrent Events #10329
Comments
Is it possible to assemble a demo using std types and preferably without 9000 libraries? :) |
Why, was it too hard to paste those three lines of code into a shell? I'll have a go |
Your example is based on libraries. Libraries themselves can have errors and should not be considered in the unit test. |
I figured as this is like my third bug report regarding the MainLoop that I could indulge myself in a sarcastic winge. I'm not sure what the exchange rate is. |
using tink.CoreApi;
class Main {
static function main() {
trace("init");
var a = new Timeout(100).prj();
var b = new Timeout(2000).prj();
var c = a.merge(b,(_,_) -> Noise);
c.handle(
(_) -> {
trace('done');
}
);
}
}
@:forward abstract Timeout(Future<Noise>){
public function new(ms:Int){
final id = Math.round(Math.random() * 1000);
trace('timeout#$id: $ms');
final multiplier = 1.02;
function step(time:Int){
return Math.round(time * multiplier);
}
this = new Future(
(cb) -> {
final start = haxe.Timer.stamp();
function exit_time(){
return start + (ms/1000);
}
function is_finished(){
return haxe.Timer.stamp() >= exit_time();
}
function since(){
return haxe.Timer.stamp() - start;
}
var cancelled = false;
var next = 200 > ms ? ms : 200;
var event = null;
event = haxe.MainLoop.add(
() -> {
trace('timeout#${id} tick. cancelled: $cancelled time ${since()}');
if(cancelled){
event.stop();
}else{
trace('$id finished?${is_finished()}');
if(is_finished()){
trace('$id COMPLETE');
event.stop();
cb(Noise);
}else{
trace('$id CONTINUE');
next = step(next);
event.delay(next/1000);
}
}
}
);
return () -> {
cancelled = true;
}
}
);
}
public function prj():Future<Noise>{
return this;
}
} build.hxml -cp src
-lib tink_core
-D analyzer-optimize
-main Main
--interp |
This is a regression in 4.2 and it affects threaded targets only. import haxe.MainLoop;
class Main {
static function main() {
var e1 = null;
var e2 = null;
e1 = MainLoop.add(() -> {
e1.stop();
trace('e1 stop');
});
e2 = MainLoop.add(() -> {
e2.stop();
trace('e2 stop');
});
}
} |
haxe build 1d5f076
I think this should work for the unit test. There should be a bunch of logging.
mine looks like:
The text was updated successfully, but these errors were encountered: