@@ -39,17 +39,18 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
3939 private val sequentialScope =
4040 CoroutineScope (Dispatchers .Default .limitedParallelism(1 ) + CoroutineName (channelName) + SupervisorJob ())
4141
42- /* *
43- * Provides a channel-specific scope for safely executing asynchronous operations with callbacks.
44- */
45- private val callbackScope = ObjectsCallbackScope (channelName)
46-
4742 /* *
4843 * Event bus for handling incoming object messages sequentially.
44+ * Processes messages inside [incomingObjectsHandler] job created using [sequentialScope].
4945 */
5046 private val objectsEventBus = MutableSharedFlow <ProtocolMessage >(extraBufferCapacity = UNLIMITED )
5147 private val incomingObjectsHandler: Job
5248
49+ /* *
50+ * Provides a channel-specific scope for safely executing asynchronous operations with callbacks.
51+ */
52+ private val asyncScope = ObjectsAsyncScope (channelName)
53+
5354 init {
5455 incomingObjectsHandler = initializeHandlerForIncomingObjectMessages()
5556 }
@@ -73,7 +74,7 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
7374 }
7475
7576 override fun getRootAsync (callback : Callback <LiveMap >) {
76- callbackScope .launchWithCallback(callback) { getRootAsync() }
77+ asyncScope .launchWithCallback(callback) { getRootAsync() }
7778 }
7879
7980 override fun createMapAsync (callback : Callback <LiveMap >) {
@@ -205,6 +206,6 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
205206 objectsManager.dispose()
206207 // Don't cancel sequentialScope (needed in getRoot method), just cancel ongoing coroutines
207208 sequentialScope.coroutineContext.cancelChildren(disposeReason)
208- callbackScope .cancel(disposeReason) // cancel all ongoing callbacks
209+ asyncScope .cancel(disposeReason) // cancel all ongoing callbacks
209210 }
210211}
0 commit comments