Skip to content

Commit 903e278

Browse files
authored
fix comment to better reflect async open logic (#7025)
1 parent e88de8b commit 903e278

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/realm/object-store/sync/async_open_task.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,11 @@ void AsyncOpenTask::attach_to_subscription_initializer(AsyncOpenCallback&& async
122122
std::shared_ptr<_impl::RealmCoordinator> coordinator,
123123
bool rerun_on_launch)
124124
{
125-
// Subscription initialization will occure in either of these 2 cases.
126-
// 1. The realm file has been created (this is the first time we ever open the file). The latest
127-
// subscription version must be 0 when we open realm for the first time, and then become 1 as soon as the
128-
// subscription is committed. This will happen when the subscription initializer callback is invoked by
129-
// coordinator->get_realm().
130-
// 2. we are instructed to run the subscription initializer via sync_config->rerun_init_subscription_on_open.
131-
// But we do that only if this is the first time we open realm.
125+
// Attaching the subscription initializer to the latest subscription that was committed.
126+
// This is going to be enough, for waiting that the subscription committed by init_subscription_initializer has
127+
// been completed (either if it is the first time that the file is created or if rerun on launch was set to true).
128+
// If the same Realm file is already opened, there is the possibility that this code may wait on a subscription
129+
// that was not committed by init_subscription_initializer.
132130

133131
auto shared_realm = coordinator->get_realm(nullptr, m_db_first_open);
134132
const auto init_subscription = shared_realm->get_latest_subscription_set();

0 commit comments

Comments
 (0)