@@ -38,17 +38,18 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
3838 private val sequentialScope =
3939 CoroutineScope (Dispatchers .Default .limitedParallelism(1 ) + CoroutineName (channelName) + SupervisorJob ())
4040
41- /* *
42- * Provides a channel-specific scope for safely executing asynchronous operations with callbacks.
43- */
44- private val callbackScope = ObjectsCallbackScope (channelName)
45-
4641 /* *
4742 * Event bus for handling incoming object messages sequentially.
43+ * Processes messages inside [incomingObjectsHandler] job created using [sequentialScope].
4844 */
4945 private val objectsEventBus = MutableSharedFlow <ProtocolMessage >(extraBufferCapacity = UNLIMITED )
5046 private val incomingObjectsHandler: Job
5147
48+ /* *
49+ * Provides a channel-specific scope for safely executing asynchronous operations with callbacks.
50+ */
51+ private val asyncScope = ObjectsAsyncScope (channelName)
52+
5253 init {
5354 incomingObjectsHandler = initializeHandlerForIncomingObjectMessages()
5455 }
@@ -68,7 +69,7 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
6869 }
6970
7071 override fun getRootAsync (callback : Callback <LiveMap >) {
71- callbackScope .launchWithCallback(callback) { getRootAsync() }
72+ asyncScope .launchWithCallback(callback) { getRootAsync() }
7273 }
7374
7475 override fun createMapAsync (liveMap : LiveMap , callback : Callback <LiveMap >) {
@@ -204,6 +205,6 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
204205 objectsManager.dispose()
205206 // Don't cancel sequentialScope (needed in getRoot method), just cancel ongoing coroutines
206207 sequentialScope.coroutineContext.cancelChildren(disposeReason)
207- callbackScope .cancel(disposeReason) // cancel all ongoing callbacks
208+ asyncScope .cancel(disposeReason) // cancel all ongoing callbacks
208209 }
209210}
0 commit comments