Rename AsyncQuery to ResultsNotifier

This commit is contained in:
Thomas Goyne 2016-03-09 11:53:08 -08:00
parent 424f4e829f
commit 4ec1090c05
7 changed files with 31 additions and 31 deletions

View File

@ -7,10 +7,10 @@ set(SOURCES
results.cpp results.cpp
schema.cpp schema.cpp
shared_realm.cpp shared_realm.cpp
impl/async_query.cpp
impl/background_collection.cpp impl/background_collection.cpp
impl/list_notifier.cpp impl/list_notifier.cpp
impl/realm_coordinator.cpp impl/realm_coordinator.cpp
impl/results_notifier.cpp
impl/transact_log_handler.cpp impl/transact_log_handler.cpp
parser/parser.cpp parser/parser.cpp
parser/query_builder.cpp) parser/query_builder.cpp)
@ -24,11 +24,11 @@ set(HEADERS
results.hpp results.hpp
schema.hpp schema.hpp
shared_realm.hpp shared_realm.hpp
impl/async_query.hpp
impl/background_collection.hpp impl/background_collection.hpp
impl/external_commit_helper.hpp impl/external_commit_helper.hpp
impl/list_notifier.hpp impl/list_notifier.hpp
impl/realm_coordinator.hpp impl/realm_coordinator.hpp
impl/results_notifier.hpp
impl/transact_log_handler.hpp impl/transact_log_handler.hpp
impl/weak_realm_notifier.hpp impl/weak_realm_notifier.hpp
impl/weak_realm_notifier_base.hpp impl/weak_realm_notifier_base.hpp

View File

@ -18,11 +18,11 @@
#include "impl/realm_coordinator.hpp" #include "impl/realm_coordinator.hpp"
#include "impl/async_query.hpp"
#include "impl/weak_realm_notifier.hpp"
#include "impl/external_commit_helper.hpp" #include "impl/external_commit_helper.hpp"
#include "impl/list_notifier.hpp" #include "impl/list_notifier.hpp"
#include "impl/results_notifier.hpp"
#include "impl/transact_log_handler.hpp" #include "impl/transact_log_handler.hpp"
#include "impl/weak_realm_notifier.hpp"
#include "object_store.hpp" #include "object_store.hpp"
#include "schema.hpp" #include "schema.hpp"

View File

@ -16,7 +16,7 @@
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
#include "impl/async_query.hpp" #include "impl/results_notifier.hpp"
#include "impl/realm_coordinator.hpp" #include "impl/realm_coordinator.hpp"
#include "results.hpp" #include "results.hpp"
@ -24,7 +24,7 @@
using namespace realm; using namespace realm;
using namespace realm::_impl; using namespace realm::_impl;
AsyncQuery::AsyncQuery(Results& target) ResultsNotifier::ResultsNotifier(Results& target)
: BackgroundCollection(target.get_realm()) : BackgroundCollection(target.get_realm())
, m_target_results(&target) , m_target_results(&target)
, m_sort(target.get_sort()) , m_sort(target.get_sort())
@ -34,7 +34,7 @@ AsyncQuery::AsyncQuery(Results& target)
m_query_handover = Realm::Internal::get_shared_group(get_realm()).export_for_handover(q, MutableSourcePayload::Move); m_query_handover = Realm::Internal::get_shared_group(get_realm()).export_for_handover(q, MutableSourcePayload::Move);
} }
void AsyncQuery::release_data() noexcept void ResultsNotifier::release_data() noexcept
{ {
m_query = nullptr; m_query = nullptr;
} }
@ -74,13 +74,13 @@ static bool map_moves(size_t& idx, CollectionChangeIndices const& changes)
return false; return false;
} }
void AsyncQuery::do_add_required_change_info(TransactionChangeInfo& info) void ResultsNotifier::do_add_required_change_info(TransactionChangeInfo& info)
{ {
REALM_ASSERT(m_query); REALM_ASSERT(m_query);
m_info = &info; m_info = &info;
} }
void AsyncQuery::run() void ResultsNotifier::run()
{ {
REALM_ASSERT(m_info); REALM_ASSERT(m_info);
@ -147,7 +147,7 @@ void AsyncQuery::run()
} }
} }
void AsyncQuery::do_prepare_handover(SharedGroup& sg) void ResultsNotifier::do_prepare_handover(SharedGroup& sg)
{ {
if (!m_tv.is_attached()) { if (!m_tv.is_attached()) {
return; return;
@ -167,7 +167,7 @@ void AsyncQuery::do_prepare_handover(SharedGroup& sg)
m_tv = {}; m_tv = {};
} }
bool AsyncQuery::do_deliver(SharedGroup& sg) bool ResultsNotifier::do_deliver(SharedGroup& sg)
{ {
std::lock_guard<std::mutex> target_lock(m_target_mutex); std::lock_guard<std::mutex> target_lock(m_target_mutex);
@ -196,13 +196,13 @@ bool AsyncQuery::do_deliver(SharedGroup& sg)
return true; return true;
} }
void AsyncQuery::do_attach_to(SharedGroup& sg) void ResultsNotifier::do_attach_to(SharedGroup& sg)
{ {
REALM_ASSERT(m_query_handover); REALM_ASSERT(m_query_handover);
m_query = sg.import_from_handover(std::move(m_query_handover)); m_query = sg.import_from_handover(std::move(m_query_handover));
} }
void AsyncQuery::do_detach_from(SharedGroup& sg) void ResultsNotifier::do_detach_from(SharedGroup& sg)
{ {
REALM_ASSERT(m_query); REALM_ASSERT(m_query);
REALM_ASSERT(!m_tv.is_attached()); REALM_ASSERT(!m_tv.is_attached());

View File

@ -16,8 +16,8 @@
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
#ifndef REALM_ASYNC_QUERY_HPP #ifndef REALM_RESULTS_NOTIFIER_HPP
#define REALM_ASYNC_QUERY_HPP #define REALM_RESULTS_NOTIFIER_HPP
#include "background_collection.hpp" #include "background_collection.hpp"
#include "results.hpp" #include "results.hpp"
@ -35,9 +35,9 @@ namespace realm {
namespace _impl { namespace _impl {
struct TransactionChangeInfo; struct TransactionChangeInfo;
class AsyncQuery : public BackgroundCollection { class ResultsNotifier : public BackgroundCollection {
public: public:
AsyncQuery(Results& target); ResultsNotifier(Results& target);
private: private:
// Run/rerun the query if needed // Run/rerun the query if needed
@ -84,4 +84,4 @@ private:
} // namespace _impl } // namespace _impl
} // namespace realm } // namespace realm
#endif /* REALM_ASYNC_QUERY_HPP */ #endif /* REALM_RESULTS_NOTIFIER_HPP */

View File

@ -18,8 +18,8 @@
#include "results.hpp" #include "results.hpp"
#include "impl/async_query.hpp"
#include "impl/realm_coordinator.hpp" #include "impl/realm_coordinator.hpp"
#include "impl/results_notifier.hpp"
#include "object_store.hpp" #include "object_store.hpp"
#include <stdexcept> #include <stdexcept>
@ -182,7 +182,7 @@ void Results::update_tableview()
return; return;
} }
if (!m_background_query && !m_realm->is_in_transaction() && m_realm->can_deliver_notifications()) { if (!m_background_query && !m_realm->is_in_transaction() && m_realm->can_deliver_notifications()) {
m_background_query = std::make_shared<_impl::AsyncQuery>(*this); m_background_query = std::make_shared<_impl::ResultsNotifier>(*this);
_impl::RealmCoordinator::register_query(m_background_query); _impl::RealmCoordinator::register_query(m_background_query);
} }
m_has_used_table_view = true; m_has_used_table_view = true;
@ -370,7 +370,7 @@ void Results::prepare_async()
} }
if (!m_background_query) { if (!m_background_query) {
m_background_query = std::make_shared<_impl::AsyncQuery>(*this); m_background_query = std::make_shared<_impl::ResultsNotifier>(*this);
_impl::RealmCoordinator::register_query(m_background_query); _impl::RealmCoordinator::register_query(m_background_query);
} }
} }

View File

@ -35,7 +35,7 @@ class Results;
class ObjectSchema; class ObjectSchema;
namespace _impl { namespace _impl {
class AsyncQuery; class ResultsNotifier;
} }
struct SortOrder { struct SortOrder {
@ -181,10 +181,10 @@ public:
bool wants_background_updates() const { return m_wants_background_updates; } bool wants_background_updates() const { return m_wants_background_updates; }
// Helper type to let AsyncQuery update the tableview without giving access // Helper type to let ResultsNotifier update the tableview without giving access
// to any other privates or letting anyone else do so // to any other privates or letting anyone else do so
class Internal { class Internal {
friend class _impl::AsyncQuery; friend class _impl::ResultsNotifier;
static void set_table_view(Results& results, TableView&& tv); static void set_table_view(Results& results, TableView&& tv);
}; };
@ -197,7 +197,7 @@ private:
SortOrder m_sort; SortOrder m_sort;
bool m_live = true; bool m_live = true;
std::shared_ptr<_impl::AsyncQuery> m_background_query; std::shared_ptr<_impl::ResultsNotifier> m_background_query;
Mode m_mode = Mode::Empty; Mode m_mode = Mode::Empty;
bool m_has_used_table_view = false; bool m_has_used_table_view = false;

View File

@ -32,19 +32,19 @@
namespace realm { namespace realm {
class BindingContext; class BindingContext;
class Replication;
class Group; class Group;
class Realm; class Realm;
class RealmDelegate; class RealmDelegate;
class Replication;
class SharedGroup; class SharedGroup;
typedef std::shared_ptr<Realm> SharedRealm; typedef std::shared_ptr<Realm> SharedRealm;
typedef std::weak_ptr<Realm> WeakRealm; typedef std::weak_ptr<Realm> WeakRealm;
namespace _impl { namespace _impl {
class AsyncQuery;
class BackgroundCollection; class BackgroundCollection;
class ListNotifier; class ListNotifier;
class RealmCoordinator; class RealmCoordinator;
class ResultsNotifier;
} }
class Realm : public std::enable_shared_from_this<Realm> { class Realm : public std::enable_shared_from_this<Realm> {
@ -145,13 +145,13 @@ namespace realm {
// Expose some internal functionality to other parts of the ObjectStore // Expose some internal functionality to other parts of the ObjectStore
// without making it public to everyone // without making it public to everyone
class Internal { class Internal {
friend class _impl::AsyncQuery;
friend class _impl::ListNotifier;
friend class _impl::BackgroundCollection; friend class _impl::BackgroundCollection;
friend class _impl::ListNotifier;
friend class _impl::RealmCoordinator; friend class _impl::RealmCoordinator;
friend class _impl::ResultsNotifier;
// AsyncQuery needs access to the SharedGroup to be able to call the // ResultsNotifier and ListNotifier need access to the SharedGroup
// handover functions, which are not very wrappable // to be able to call the handover functions, which are not very wrappable
static SharedGroup& get_shared_group(Realm& realm) { return *realm.m_shared_group; } static SharedGroup& get_shared_group(Realm& realm) { return *realm.m_shared_group; }
// BackgroundCollection needs to be able to access the owning // BackgroundCollection needs to be able to access the owning