@@ -29,15 +29,15 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
29
29
private [this ] final val Undefined = " undefined"
30
30
31
31
def execute (runnable : Runnable ): Unit =
32
- setImmediate(() => runnable.run() )
32
+ setImmediate(runnable)
33
33
34
34
def reportFailure (cause : Throwable ): Unit =
35
35
cause.printStackTrace()
36
36
37
- private [this ] val setImmediate : (() => Unit ) => Unit = {
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 , () => Unit ]()
40
+ val tasksByHandle = mutable.Map [Int , Runnable ]()
41
41
var currentlyRunningATask = false
42
42
43
43
def canUsePostMessage (): Boolean = {
@@ -71,7 +71,7 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
71
71
case Some (task) =>
72
72
currentlyRunningATask = true
73
73
try {
74
- task()
74
+ task.run ()
75
75
} finally {
76
76
tasksByHandle -= handle
77
77
currentlyRunningATask = false
@@ -95,7 +95,7 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
95
95
js.Dynamic .global.Node .constructor(" return setImmediate" )()
96
96
97
97
{ k =>
98
- setImmediate(k )
98
+ setImmediate(() => k.run() )
99
99
()
100
100
}
101
101
} else if (canUsePostMessage()) {
@@ -153,13 +153,13 @@ object MacrotaskExecutor extends ExecutionContextExecutor {
153
153
// we're also not going to bother fast-pathing for IE6; just fall through
154
154
155
155
{ k =>
156
- js.Dynamic .global.setTimeout(k , 0 )
156
+ js.Dynamic .global.setTimeout(() => k.run() , 0 )
157
157
()
158
158
}
159
159
}
160
160
} else {
161
161
{ k =>
162
- js.Dynamic .global.setImmediate(k )
162
+ js.Dynamic .global.setImmediate(() => k.run() )
163
163
()
164
164
}
165
165
}
0 commit comments