Skip to content

Commit

Permalink
Client reset: use ThreadSafeReference instead of SharedRealm (related…
Browse files Browse the repository at this point in the history
  • Loading branch information
kneth committed Jun 16, 2022
1 parent fd48276 commit b00e7ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/realm/object-store/sync/sync_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <realm/object-store/sync/sync_session.hpp>

#include <realm/object-store/thread_safe_reference.hpp>
#include <realm/object-store/impl/realm_coordinator.hpp>
#include <realm/object-store/sync/app.hpp>
#include <realm/object-store/sync/impl/sync_client.hpp>
Expand Down Expand Up @@ -608,19 +609,18 @@ static sync::Session::Config::ClientReset make_client_reset_config(SyncConfig& s
config.notify_after_client_reset = [notify = session_config.notify_after_client_reset](
std::string local_path, VersionID previous_version, bool did_recover) {
REALM_ASSERT(!local_path.empty());
SharedRealm frozen_before, active_after;
SharedRealm frozen_before;
ThreadSafeReference active_after;
if (auto local_coordinator = RealmCoordinator::get_existing_coordinator(local_path)) {
auto local_config = local_coordinator->get_config();
active_after = local_coordinator->get_realm(local_config, util::none);
active_after = local_coordinator->get_unbound_realm();
local_config.scheduler = nullptr;
frozen_before = local_coordinator->get_realm(local_config, previous_version);
REALM_ASSERT(active_after);
REALM_ASSERT(!active_after->is_frozen());
REALM_ASSERT(frozen_before);
REALM_ASSERT(frozen_before->is_frozen());
}
if (notify) {
notify(frozen_before, active_after, did_recover);
notify(frozen_before, std::move(active_after), did_recover);
}
};
config.notify_before_client_reset = [notify = session_config.notify_before_client_reset](std::string local_path) {
Expand Down
3 changes: 2 additions & 1 deletion src/realm/sync/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace realm {
class SyncUser;
class SyncSession;
class Realm;
class ThreadSafeReference;

namespace bson {
class Bson;
Expand Down Expand Up @@ -182,7 +183,7 @@ struct SyncConfig {
util::Optional<std::string> recovery_directory;
ClientResyncMode client_resync_mode = ClientResyncMode::Manual;
std::function<void(std::shared_ptr<Realm> before_frozen)> notify_before_client_reset;
std::function<void(std::shared_ptr<Realm> before_frozen, std::shared_ptr<Realm> after, bool did_recover)>
std::function<void(std::shared_ptr<Realm> before_frozen, ThreadSafeReference after, bool did_recover)>
notify_after_client_reset;

// Will be called after a download message is received and validated by the client but befefore it's been
Expand Down

0 comments on commit b00e7ed

Please sign in to comment.