File tree 1 file changed +11
-13
lines changed
core/src/main/scala/org/scalajs/macrotaskexecutor
1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package org .scalajs .macrotaskexecutor
18
18
19
- import scala . collection . mutable
19
+ import java . util . HashMap
20
20
import scala .concurrent .{ExecutionContext , ExecutionContextExecutor }
21
21
import scala .scalajs .js
22
22
import scala .util .Random
@@ -37,7 +37,7 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
37
37
private [this ] val setImmediate : Runnable => Unit = {
38
38
if (js.typeOf(js.Dynamic .global.setImmediate) == Undefined ) {
39
39
var nextHandle = 1
40
- val tasksByHandle = mutable. Map [Int , Runnable ]()
40
+ val tasksByHandle = new HashMap [Int , Runnable ]
41
41
var currentlyRunningATask = false
42
42
43
43
def canUsePostMessage (): Boolean = {
@@ -67,17 +67,15 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
67
67
if (currentlyRunningATask) {
68
68
js.Dynamic .global.setTimeout(() => runIfPresent(handle), 0 )
69
69
} else {
70
- tasksByHandle.get(handle) match {
71
- case Some (task) =>
72
- currentlyRunningATask = true
73
- try {
74
- task.run()
75
- } finally {
76
- tasksByHandle -= handle
77
- currentlyRunningATask = false
78
- }
79
-
80
- case None =>
70
+ val task = tasksByHandle.get(handle)
71
+ if (task ne null ) {
72
+ currentlyRunningATask = true
73
+ try {
74
+ task.run()
75
+ } finally {
76
+ tasksByHandle -= handle
77
+ currentlyRunningATask = false
78
+ }
81
79
}
82
80
}
83
81
You can’t perform that action at this time.
0 commit comments