Skip to content

Commit 0e7e377

Browse files
committed
Merge branch 'feature/server-provided-tombstone-serial' into feature/liveobjects-realtime-write-api
2 parents 83c3c6a + 4c17445 commit 0e7e377

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjects.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

live-objects/src/main/kotlin/io/ably/lib/objects/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal val String.byteSize: Int
5454
* Provides safe execution of suspend functions with results delivered via callbacks.
5555
* Supports proper error handling and cancellation during LiveObjects disposal.
5656
*/
57-
internal class ObjectsCallbackScope(channelName: String) {
57+
internal class ObjectsAsyncScope(channelName: String) {
5858
private val tag = "ObjectsCallbackScope-$channelName"
5959

6060
private val scope =

0 commit comments

Comments
 (0)