-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition when disposing WorkRunners in an active loop
- Loading branch information
1 parent
b091bd1
commit 90f274b
Showing
11 changed files
with
108 additions
and
68 deletions.
There are no files selected for viewing
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
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
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
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
18 changes: 14 additions & 4 deletions
18
mobiuskt-core/src/jvmMain/kotlin/runners/ExecutorServiceWorkRunner.kt
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
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
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
43 changes: 0 additions & 43 deletions
43
mobiuskt-core/src/jvmTest/kotlin/MobiusLoopErrorReporting.kt
This file was deleted.
Oops, something went wrong.
12 changes: 10 additions & 2 deletions
12
mobiuskt-core/src/nativeMain/kotlin/runners/NativeWorkRunner.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
package kt.mobius.runners | ||
|
||
import kotlinx.atomicfu.locks.SynchronizedObject | ||
import kotlinx.atomicfu.locks.synchronized | ||
import kotlin.native.concurrent.Worker | ||
|
||
public class NativeWorkRunner( | ||
private val worker: Worker | ||
) : WorkRunner { | ||
|
||
private val lock = SynchronizedObject() | ||
|
||
init { | ||
check(Platform.memoryModel == MemoryModel.EXPERIMENTAL) { | ||
"Using NativeWorkRunner requires the experimental memory model.\nSee https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md" | ||
} | ||
} | ||
|
||
override fun post(runnable: Runnable) { | ||
worker.executeAfter(operation = runnable::run) | ||
synchronized(lock) { | ||
worker.executeAfter(operation = runnable::run) | ||
} | ||
} | ||
|
||
override fun dispose() { | ||
worker.requestTermination(processScheduledJobs = false) | ||
synchronized(lock) { | ||
worker.requestTermination(processScheduledJobs = false) | ||
} | ||
} | ||
} |
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
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