Loop.hx 895 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package hl.uv;
  2. @:enum abstract LoopRunMode(Int) {
  3. var Default = 0;
  4. var Once = 1;
  5. var NoWait = 2;
  6. }
  7. abstract Loop(hl.Abstract<"uv_loop">) {
  8. @:hlNative("uv","loop_close") public function close() : Int {
  9. return 0;
  10. }
  11. @:hlNative("uv","run") public function run( mode : LoopRunMode ) : Int {
  12. return 0;
  13. }
  14. @:hlNative("uv","loop_alive") public function alive() : Int {
  15. return 0;
  16. }
  17. @:hlNative("uv","stop") public function stop() : Void {
  18. }
  19. @:hlNative("uv","default_loop")
  20. public static function getDefault() : Loop {
  21. return null;
  22. }
  23. /**
  24. Register the default loop into the main haxe loop.
  25. Should be called at least once unless you want to integrate the loop update yourself.
  26. **/
  27. public static function register() {
  28. if( initDone ) return;
  29. initDone = true;
  30. var def = getDefault();
  31. haxe.MainLoop.add(function() def.run(NoWait));
  32. }
  33. static var initDone = false;
  34. }