[Git][ghc/ghc][master] 2 commits: Add support for environments that don't have setImmediate

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Dec 9 14:43:56 UTC 2022



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
79b0cec0 by Luite Stegeman at 2022-12-09T09:43:38-05:00
Add support for environments that don't have setImmediate

- - - - -
5b007ec5 by Luite Stegeman at 2022-12-09T09:43:38-05:00
Fix bound thread status

- - - - -


1 changed file:

- rts/js/thread.js


Changes:

=====================================
rts/js/thread.js
=====================================
@@ -153,7 +153,7 @@ function h$forkThread(a, inherit) {
 
 function h$threadStatus(t) {
   // status, capability, locked
-  RETURN_UBX_TUP3(t.status, 1, 0);
+  RETURN_UBX_TUP3(t.status, 0, 1);
 }
 
 function h$waitRead(fd) {
@@ -599,7 +599,7 @@ function h$scheduleMainLoop() {
             // node.js 0.10.30 has trouble with non-integral delays
             h$mainLoopTimeout = setTimeout(h$mainLoop, Math.round(delay));
         } else {
-            h$mainLoopImmediate = setImmediate(h$mainLoop);
+            h$mainLoopImmediate = h$setImmediate(h$mainLoop);
         }
 #ifndef GHCJS_BROWSER
     }
@@ -617,7 +617,7 @@ function h$clearScheduleMainLoop() {
         h$mainLoopTimeout = null;
     }
     if(h$mainLoopImmediate) {
-        clearImmediate(h$mainLoopImmediate);
+        h$clearImmediate(h$mainLoopImmediate);
         h$mainLoopImmediate = null;
     }
     if(h$mainLoopFrame) {
@@ -626,6 +626,15 @@ function h$clearScheduleMainLoop() {
     }
 }
 
+var h$setImmediate, h$clearImmediate;
+if(typeof setImmediate !== 'undefined') {
+  h$setImmediate = function(f) { return setImmediate(f); }
+  h$clearImmediate = function(h) { clearImmediate(h); }
+} else {
+  h$setImmediate = function(f) { return setTimeout(f, 0); }
+  h$clearImmediate = function(h) { clearTimeout(h); }
+}
+
 function h$startMainLoop() {
     TRACE_SCHEDULER("start main loop: " + h$running)
     if(h$running) return;
@@ -634,7 +643,7 @@ function h$startMainLoop() {
 #endif
         if(!h$mainLoopImmediate) {
             h$clearScheduleMainLoop();
-            h$mainLoopImmediate = setImmediate(h$mainLoop);
+            h$mainLoopImmediate = h$setImmediate(h$mainLoop);
         }
 #ifndef GHCJS_BROWSER
     } else {
@@ -717,7 +726,7 @@ function h$actualMainLoop() {
       if(h$animationFrameMainLoop) {
         h$mainLoopFrame = requestAnimationFrame(h$mainLoop);
       } else {
-        h$mainLoopImmediate = setImmediate(h$mainLoop);
+        h$mainLoopImmediate = h$setImmediate(h$mainLoop);
       }
       return;
     }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1023b432d0befd9675dcfcfb44c548b06b2fae8c...5b007ec52ba77051fedd2b9a6fb155b248081511

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1023b432d0befd9675dcfcfb44c548b06b2fae8c...5b007ec52ba77051fedd2b9a6fb155b248081511
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221209/375319f1/attachment-0001.html>


More information about the ghc-commits mailing list