Skip to content

Commit

Permalink
wip implementing a mechanism for #155 that i'm not 100% sure what it'…
Browse files Browse the repository at this point in the history
…ll turn out to be

this first part is just a refactor, then we'll bulk it out with giving
priority to other things
  • Loading branch information
lawrence-forooghian committed Dec 11, 2024
1 parent d5a10fd commit 70a9c51
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Sources/AblyChat/RoomLifecycleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,16 @@ internal actor DefaultRoomLifecycleManager<Contributor: RoomLifecycleContributor
}
#endif

// TODO what is this
private func waitForCompletionOfAnyInProgressOperation(
waitingOperationID: UUID
) async {
// CHA-RL1d, CHA-RL2i, CHA-RL3k
if let currentOperationID = status.operationID {
try? await waitForCompletionOfOperationWithID(currentOperationID, waitingOperationID: waitingOperationID)
}
}

/// Waits for the operation with ID `waitedOperationID` to complete, re-throwing any error thrown by that operation.
///
/// Note that this method currently treats all waited operations as throwing. If you wish to wait for an operation that you _know_ to be non-throwing (which the RELEASE operation currently is) then you’ll need to call this method with `try!` or equivalent. (It might be possible to improve this in the future, but I didn’t want to put much time into figuring it out.)
Expand Down Expand Up @@ -787,9 +797,7 @@ internal actor DefaultRoomLifecycleManager<Contributor: RoomLifecycleContributor
}

// CHA-RL1d
if let currentOperationID = status.operationID {
try? await waitForCompletionOfOperationWithID(currentOperationID, waitingOperationID: operationID)
}
await waitForCompletionOfAnyInProgressOperation(waitingOperationID: operationID)

// CHA-RL1e
changeStatus(to: .attachingDueToAttachOperation(attachOperationID: operationID))
Expand Down Expand Up @@ -909,9 +917,7 @@ internal actor DefaultRoomLifecycleManager<Contributor: RoomLifecycleContributor
}

// CHA-RL2i
if let currentOperationID = status.operationID {
try? await waitForCompletionOfOperationWithID(currentOperationID, waitingOperationID: operationID)
}
await waitForCompletionOfAnyInProgressOperation(waitingOperationID: operationID)

// CHA-RL2e
clearTransientDisconnectTimeouts()
Expand Down Expand Up @@ -1041,9 +1047,7 @@ internal actor DefaultRoomLifecycleManager<Contributor: RoomLifecycleContributor
}

// CHA-RL3k
if let currentOperationID = status.operationID {
try? await waitForCompletionOfOperationWithID(currentOperationID, waitingOperationID: operationID)
}
await waitForCompletionOfAnyInProgressOperation(waitingOperationID: operationID)

// CHA-RL3l
clearTransientDisconnectTimeouts()
Expand Down

0 comments on commit 70a9c51

Please sign in to comment.