Advertisement
Guest User

Untitled

a guest
Mar 11th, 2025
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | Source Code | 0 0
  1. // func scheduleTimeoutEvent(delay int64) int32
  2. "runtime.scheduleTimeoutEvent": (sp) => {
  3. sp >>>= 0;
  4. const id = this._nextCallbackTimeoutID;
  5. this._nextCallbackTimeoutID++;
  6. this._scheduledTimeouts.set(id, setTimeout(
  7. () => {
  8. console.log("###### TRIGGER TIMEOUT EVENT", (this._scheduledTimeouts.get(id))[Symbol.toPrimitive]());
  9. this._resume();
  10. while (this._scheduledTimeouts.has(id)) {
  11. // for some reason Go failed to register the timeout event, log and try again
  12. // (temporary workaround for https://github.com/golang/go/issues/28975)
  13. console.warn("scheduleTimeoutEvent: missed timeout event");
  14. this._resume();
  15. }
  16. },
  17. getInt64(sp + 8),
  18. ));
  19. console.log("###### SCHEDULE TIMEOUT EVENT", (this._scheduledTimeouts.get(id))[Symbol.toPrimitive](), getInt64(sp + 8));
  20. this.mem.setInt32(sp + 16, id, true);
  21. },
  22.  
  23. // func clearTimeoutEvent(id int32)
  24. "runtime.clearTimeoutEvent": (sp) => {
  25. sp >>>= 0;
  26. const id = this.mem.getInt32(sp + 8, true);
  27. console.log("###### CLEAR TIMEOUT EVENT", (this._scheduledTimeouts.get(id))[Symbol.toPrimitive]());
  28. clearTimeout(this._scheduledTimeouts.get(id));
  29. this._scheduledTimeouts.delete(id);
  30. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement