コード例 #1
0
bool ResultsNotifier::do_deliver(SharedGroup& sg)
{
    auto lock = lock_target();

    // Target realm being null here indicates that we were unregistered while we
    // were in the process of advancing the Realm version and preparing for
    // delivery, i.e. the results was destroyed from the "wrong" thread
    if (!get_realm()) {
        return false;
    }

    // We can get called before the query has actually had the chance to run if
    // we're added immediately before a different set of async results are
    // delivered
    if (!m_initial_run_complete) {
        return false;
    }

    REALM_ASSERT(!m_query_handover);

    if (m_tv_handover) {
        m_tv_handover->version = version();
        Results::Internal::set_table_view(*m_target_results,
                                          std::move(*sg.import_from_handover(std::move(m_tv_handover))));
    }
    REALM_ASSERT(!m_tv_handover);
    return true;
}
コード例 #2
0
void ResultsNotifier::do_attach_to(SharedGroup& sg)
{
    REALM_ASSERT(m_query_handover);
    m_query = sg.import_from_handover(std::move(m_query_handover));
    m_sort = SortDescriptor::create_from_and_consume_patch(m_sort_handover, *m_query->get_table());
    m_distinct = SortDescriptor::create_from_and_consume_patch(m_distinct_handover, *m_query->get_table());
}
コード例 #3
0
void ResultsNotifier::do_detach_from(SharedGroup& sg)
{
    REALM_ASSERT(m_query);
    REALM_ASSERT(!m_tv.is_attached());

    m_query_handover = sg.export_for_handover(*m_query, MutableSourcePayload::Move);
    m_query = nullptr;
}
コード例 #4
0
void ObjectNotifier::do_detach_from(SharedGroup& sg)
{
    REALM_ASSERT(!m_handover);
    if (m_row) {
        m_handover = sg.export_for_handover(*m_row);
        m_row = nullptr;
    }
}
コード例 #5
0
ファイル: list_notifier.cpp プロジェクト: BizBuzz/Backend
void ListNotifier::do_detach_from(SharedGroup& sg)
{
    REALM_ASSERT(!m_lv_handover);
    if (m_lv) {
        m_lv_handover = sg.export_linkview_for_handover(m_lv);
        m_lv = {};
    }
}
コード例 #6
0
void PrimitiveListNotifier::do_detach_from(SharedGroup& sg)
{
    REALM_ASSERT(!m_table_handover);
    if (m_table) {
        m_table_handover = sg.export_table_for_handover(m_table);
        m_table = {};
    }
}
コード例 #7
0
void ResultsNotifier::do_detach_from(SharedGroup& sg)
{
    REALM_ASSERT(m_query);
    REALM_ASSERT(!m_tv.is_attached());

    SortDescriptor::generate_patch(m_sort, m_sort_handover);
    SortDescriptor::generate_patch(m_distinct, m_distinct_handover);
    m_query_handover = sg.export_for_handover(*m_query, MutableSourcePayload::Move);
    m_query = nullptr;
}
コード例 #8
0
void ResultsNotifier::do_prepare_handover(SharedGroup& sg)
{
    if (!m_tv.is_attached()) {
        // if the table version didn't change we can just reuse the same handover
        // object and bump its version to the current SG version
        if (m_tv_handover)
            m_tv_handover->version = sg.get_version_of_current_transaction();
        return;
    }

    REALM_ASSERT(m_tv.is_in_sync());

    m_tv_handover = sg.export_for_handover(m_tv, MutableSourcePayload::Move);

    add_changes(std::move(m_changes));
    REALM_ASSERT(m_changes.empty());

    // detach the TableView as we won't need it again and keeping it around
    // makes advance_read() much more expensive
    m_tv = {};
}
コード例 #9
0
void NotifierPackage::deliver(SharedGroup& sg)
{
    if (m_error) {
        for (auto& notifier : m_notifiers)
            notifier->deliver_error(m_error);
        return;
    }
    // Can't deliver while in a write transaction
    if (sg.get_transact_stage() != SharedGroup::transact_Reading)
        return;
    for (auto& notifier : m_notifiers)
        notifier->deliver(sg);
}
コード例 #10
0
void ResultsNotifier::do_prepare_handover(SharedGroup& sg)
{
    if (!m_tv.is_attached()) {
        return;
    }

    REALM_ASSERT(m_tv.is_in_sync());

    m_initial_run_complete = true;
    m_tv_handover = sg.export_for_handover(m_tv, MutableSourcePayload::Move);

    add_changes(std::move(m_changes));
    REALM_ASSERT(m_changes.empty());

    // detach the TableView as we won't need it again and keeping it around
    // makes advance_read() much more expensive
    m_tv = {};
}
コード例 #11
0
void ResultsNotifier::deliver(SharedGroup& sg)
{
    auto lock = lock_target();

    // Target realm being null here indicates that we were unregistered while we
    // were in the process of advancing the Realm version and preparing for
    // delivery, i.e. the results was destroyed from the "wrong" thread
    if (!get_realm()) {
        return;
    }

    REALM_ASSERT(!m_query_handover);
    if (m_tv_to_deliver) {
        Results::Internal::set_table_view(*m_target_results,
                                          std::move(*sg.import_from_handover(std::move(m_tv_to_deliver))));
    }
    REALM_ASSERT(!m_tv_to_deliver);
}
コード例 #12
0
void ResultsNotifier::do_attach_to(SharedGroup& sg)
{
    REALM_ASSERT(m_query_handover);
    m_query = sg.import_from_handover(std::move(m_query_handover));
}
コード例 #13
0
void ObjectNotifier::do_attach_to(SharedGroup& sg)
{
    REALM_ASSERT(m_handover);
    REALM_ASSERT(!m_row);
    m_row = sg.import_from_handover(std::move(m_handover));
}
コード例 #14
0
inline void LangBindHelper::promote_to_write(SharedGroup& sg,
                                             TransactLogRegistry& log_registry)
{
    sg.promote_to_write(log_registry);
}
コード例 #15
0
inline void LangBindHelper::advance_read(SharedGroup& sg,
                                         TransactLogRegistry& log_registry)
{
    sg.advance_read(log_registry);
}
コード例 #16
0
void PrimitiveListNotifier::do_attach_to(SharedGroup& sg)
{
    REALM_ASSERT(m_table_handover);
    REALM_ASSERT(!m_table);
    m_table = sg.import_table_from_handover(std::move(m_table_handover));
}
コード例 #17
0
inline void LangBindHelper::commit_and_continue_as_read(SharedGroup& sg)
{
    sg.commit_and_continue_as_read();
}
コード例 #18
0
ファイル: list_notifier.cpp プロジェクト: BizBuzz/Backend
void ListNotifier::do_attach_to(SharedGroup& sg)
{
    REALM_ASSERT(m_lv_handover);
    REALM_ASSERT(!m_lv);
    m_lv = sg.import_linkview_from_handover(std::move(m_lv_handover));
}