Last active
November 27, 2019 01:11
-
-
Save Groostav/9f625d2f93e551c36ad26a7be13e0f38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FXML fun onRunButtonClick(): Job { | |
println("clicked... launch coming") | |
val job = launch(Dispatchers.Default + CoroutineName("Run-button-click")) { | |
println("launched!") | |
} | |
println("launched, job=$job") | |
Platform.runLater { | |
println("Platform.runlater: running later, job=$job") | |
println("Platform.runlater: running job in global scope") | |
GlobalScope.launch { | |
println("Platform.runlater:GlobalScope.launch: started global scope job, UIjob=$job") | |
} | |
println("Platform.runlater: attempting to dispatch directly on Disptchers.default") | |
Dispatchers.Default.dispatch(EmptyCoroutineContext, Runnable { | |
println("Platform.runlater:Dispatchers.default.dispatch: dispatched on default, UIJob=$job") | |
}) | |
println("Platform.runlater: attempting to dispatch directly on Disptchers.IO") | |
Dispatchers.IO.dispatch(EmptyCoroutineContext, Runnable { | |
println("Platform.runlater:Dispatchers.IO.dispatch: dispatched on IO") | |
}) | |
println("Platform.runlater: attempting to dispatch directly on Disptchers.JavaFx") | |
Dispatchers.JavaFx.dispatch(EmptyCoroutineContext, Runnable { | |
println("Platform.runlater:Dispatchers.JavaFx.dispatch: dispatched on JavaFx") | |
}) | |
println("Platform.runLater: calling runLater again to see if maybe UI queue is flooded...") | |
Platform.runLater { | |
println("Platform.runLater:Platform.runLater: dispatched another UI job...") | |
} | |
} | |
return job | |
} | |
/* output after running steps to repro flooding: | |
clicked... launch coming | |
launched, job="Run-button-click#1316":StandaloneCoroutine{Active}@1dd146e | |
Platform.runlater: running later, job="Run-button-click#1316":StandaloneCoroutine{Active}@1dd146e | |
Platform.runlater: running job in global scope | |
Platform.runlater: attempting to dispatch directly on Disptchers.default | |
Platform.runlater: attempting to dispatch directly on Disptchers.IO | |
Platform.runlater: attempting to dispatch directly on Disptchers.JavaFx | |
Platform.runLater: calling runLater again to see if maybe UI queue is flooded... | |
Platform.runlater:Dispatchers.JavaFx.dispatch: dispatched on JavaFx | |
Platform.runLater:Platform.runLater: dispatched another UI job... | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FXML fun onRunButtonClick(): Job { | |
println("clicked... launch coming") | |
val job = launch(Dispatchers.Default + CoroutineName("Run-button-click")) { | |
println("launched!") | |
} | |
println("launched, job=$job") | |
Platform.runLater { | |
println("Platform.runlater: running later, job=$job") | |
println("Platform.runlater: running job in global scope") | |
GlobalScope.launch { | |
println("Platform.runlater:GlobalScope.launch: started global scope job, UIjob=$job") | |
} | |
println("Platform.runlater: attempting to dispatch directly on Disptchers.default") | |
Dispatchers.Default.dispatch(EmptyCoroutineContext, Runnable { | |
println("Platform.runlater:Dispatchers.default.dispatch: dispatched on default, UIJob=$job") | |
}) | |
println("Platform.runlater: attempting to dispatch directly on Disptchers.IO") | |
Dispatchers.IO.dispatch(EmptyCoroutineContext, Runnable { | |
println("Platform.runlater:Dispatchers.IO.dispatch: dispatched on IO") | |
}) | |
println("Platform.runLater: calling runLater again to see if maybe UI queue is flooded...") | |
Platform.runLater { | |
println("Platform.runLater:Platform.runLater: dispatched another UI job...") | |
println("Platform.runLater:Platform.runLater: Dispatchers.Default=${Dispatchers.Default}") | |
println("Platform.runLater:Platform.runLater: Dispatchers.Default.toDebugString=${ReflectionUtilities.findMethod(Dispatchers.Default, "toDebugString").invoke(Dispatchers.Default)}") | |
} | |
} | |
return job | |
} | |
/* output: | |
//executed before doing steps to reproduce; things working normally (baseline) | |
clicked... launch coming | |
launched! | |
launched, job="Run-button-click#68":StandaloneCoroutine{Completed}@bd7ab0 | |
Platform.runlater: running later, job="Run-button-click#68":StandaloneCoroutine{Completed}@bd7ab0 | |
Platform.runlater: running job in global scope | |
Platform.runlater: attempting to dispatch directly on Disptchers.default | |
Platform.runlater:GlobalScope.launch: started global scope job, UIjob="Run-button-click#68":StandaloneCoroutine{Completed}@bd7ab0 | |
Platform.runlater: attempting to dispatch directly on Disptchers.IO | |
Platform.runlater:Dispatchers.default.dispatch: dispatched on default, UIJob="Run-button-click#68":StandaloneCoroutine{Completed}@bd7ab0 | |
Platform.runlater: attempting to dispatch directly on Disptchers.JavaFx | |
Platform.runlater:Dispatchers.IO.dispatch: dispatched on IO | |
Platform.runLater: calling runLater again to see if maybe UI queue is flooded... | |
Platform.runlater:Dispatchers.JavaFx.dispatch: dispatched on JavaFx | |
Platform.runLater:Platform.runLater: dispatched another UI job... | |
Platform.runLater:Platform.runLater: Dispatchers.Default=DefaultDispatcher | |
Platform.runLater:Platform.runLater: Dispatchers.Default.toDebugString=DefaultScheduler@1a8d64e[scheduler = DefaultDispatcher@1685bf3[Pool Size {core = 4, max = 512}, Worker States {CPU = 0, blocking = 0, parked = 5, retired = 0, terminated = 0}, running workers queues = [], global queue size = 0, Control State Workers {created = 5, blocking = 0}]] | |
ETPN@5198710 has exe=C:\Users\Geoff\Code\OASIS\Samples\PowerShell\SC function\sc-like polynomial.ps1 | |
//ran steps to reproduce | |
clicked... launch coming | |
launched, job="Run-button-click#804":StandaloneCoroutine{Active}@1e4145f | |
Platform.runlater: running later, job="Run-button-click#804":StandaloneCoroutine{Active}@1e4145f | |
Platform.runlater: running job in global scope | |
Platform.runlater: attempting to dispatch directly on Disptchers.default | |
Platform.runlater: attempting to dispatch directly on Disptchers.IO | |
Platform.runlater: attempting to dispatch directly on Disptchers.JavaFx | |
Platform.runLater: calling runLater again to see if maybe UI queue is flooded... | |
Platform.runlater:Dispatchers.JavaFx.dispatch: dispatched on JavaFx | |
Platform.runLater:Platform.runLater: dispatched another UI job... | |
Platform.runLater:Platform.runLater: Dispatchers.Default=DefaultDispatcher | |
Platform.runLater:Platform.runLater: Dispatchers.Default.toDebugString=DefaultScheduler@1a8d64e[scheduler = DefaultDispatcher@1685bf3[Pool Size {core = 4, max = 512}, Worker States {CPU = 4, blocking = 0, parked = 0, retired = 0, terminated = 0}, running workers queues = [1c, 0c, 1c, 0c], global queue size = 6, Control State Workers {created = 4, blocking = 0}]] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, one (i think) very important observation, If I set
kotlinx.coroutines.scheduler=off
, thenDispatchers.IO
starts responding, butDispatchers.Default
doesn't, even thoughDispatchers.Default
in that case is a wholly separateobject
instance. This means the problem is in an invariant shared byCommonPool
andDefaultScheduler