Skip to content

haxe.Timer.delay with haxe.MainLoop #7907

Description

@Aurel300
class Main {
  public static function main():Void {
    haxe.MainLoop.addThread(() -> trace("this prints"));
    haxe.Timer.delay(() -> {
        haxe.MainLoop.addThread(() -> trace("this does not print"));
      }, 0);
  }
}

Expected both to print, but only the first trace works. This is not a problem with logging – I verified by setting a value on the global object like so:

class Main {
  public static function main():Void {
    js.Syntax.code("global.someTestValue = 0");
    haxe.MainLoop.addThread(() -> js.Syntax.code("global.someTestValue = 1"));
    haxe.Timer.delay(() -> {
        haxe.MainLoop.addThread(() -> js.Syntax.code("global.someTestValue = 2"));
      }, 0);
    haxe.Timer.delay(() -> trace(js.Syntax.code("global.someTestValue")), 100);
  }
}

(Outputs 1.)

Compiled with haxe -lib hxnodejs -main Main -js test.js and executed with node test.js. Node version 8.5.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions