Skip to content

Commit 4c17445

Browse files
committed
Merge branch 'feature/object-subscriptions' into feature/server-provided-tombstone-serial
2 parents 77dec92 + c4dec91 commit 4c17445

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
@@ -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
}

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)