当前位置: 首页>>代码示例>>C++>>正文


C++ SyncSession类代码示例

本文整理汇总了C++中SyncSession的典型用法代码示例。如果您正苦于以下问题:C++ SyncSession类的具体用法?C++ SyncSession怎么用?C++ SyncSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SyncSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: revive_if_needed

 bool revive_if_needed(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     // Revive.
     session.create_sync_session();
     session.advance_state(lock, waiting_for_access_token);
     return true;
 }
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:7,代码来源:sync_session.cpp

示例2: access_token_expired

 bool access_token_expired(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     session.advance_state(lock, waiting_for_access_token);
     std::shared_ptr<SyncSession> session_ptr = session.shared_from_this();
     lock.unlock();
     session.m_config.bind_session_handler(session_ptr->m_realm_path, session_ptr->m_config, session_ptr);
     return false;
 }
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:8,代码来源:sync_session.cpp

示例3: bind_with_admin_token

 void bind_with_admin_token(std::unique_lock<std::mutex>& lock, SyncSession& session,
                            const std::string& admin_token,
                            const std::string& server_url) const override
 {
     session.create_sync_session();
     session.advance_state(lock, waiting_for_access_token);
     session.m_state->refresh_access_token(lock, session, admin_token, server_url);
 }
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:8,代码来源:sync_session.cpp

示例4: close

 void close(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     switch (session.m_config.stop_policy) {
         case SyncSessionStopPolicy::Immediately:
             session.advance_state(lock, inactive);
             break;
         case SyncSessionStopPolicy::LiveIndefinitely:
             // Don't do anything; session lives forever.
             break;
         case SyncSessionStopPolicy::AfterChangesUploaded:
             // Wait for all pending changes to upload.
             session.advance_state(lock, dying);
             break;
     }
 }
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:15,代码来源:sync_session.cpp

示例5: handle_reconnect

 void handle_reconnect(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     // Ask the binding to retry getting the token for this session.
     std::shared_ptr<SyncSession> session_ptr = session.shared_from_this();
     lock.unlock();
     session.m_config.bind_session_handler(session_ptr->m_realm_path, session_ptr->m_config, session_ptr);
 }
开发者ID:AlanAherne,项目名称:BabyTunes,代码行数:7,代码来源:sync_session.cpp

示例6: refresh_access_token

 void refresh_access_token(std::unique_lock<std::mutex>& lock, SyncSession& session,
                           std::string access_token,
                           const util::Optional<std::string>& server_url) const override
 {
     // Since the sync session was previously unbound, it's safe to do this from the
     // calling thread.
     if (!session.m_server_url) {
         session.m_server_url = server_url;
     }
     if (session.m_session_has_been_bound) {
         session.m_session->refresh(std::move(access_token));
     } else {
         session.m_session->bind(*session.m_server_url, std::move(access_token));
         session.m_session_has_been_bound = true;
     }
     if (session.m_deferred_commit_notification) {
         session.m_session->nonsync_transact_notify(*session.m_deferred_commit_notification);
         session.m_deferred_commit_notification = util::none;
     }
     session.advance_state(lock, active);
     if (session.m_deferred_close) {
         session.m_deferred_close = false;
         session.m_state->close(lock, session);
     }
 }
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:25,代码来源:sync_session.cpp

示例7: enter_state

 void enter_state(std::unique_lock<std::mutex>&, SyncSession& session) const override
 {
     size_t current_death_count = ++session.m_death_count;
     session.m_session->async_wait_for_upload_completion([session=&session, current_death_count](std::error_code) {
         std::unique_lock<std::mutex> lock(session->m_state_mutex);
         if (session->m_state == &State::dying && session->m_death_count == current_death_count) {
             session->advance_state(lock, inactive);
         }
     });
 }
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:10,代码来源:sync_session.cpp

示例8: enter_state

 void enter_state(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     // Inform any queued-up completion handlers that they were cancelled.
     for (auto& package : session.m_completion_wait_packages) {
         package.callback(util::error::operation_aborted);
     }
     session.m_completion_wait_packages.clear();
     session.m_session = nullptr;
     session.unregister(lock);
 }
开发者ID:AlanAherne,项目名称:BabyTunes,代码行数:10,代码来源:sync_session.cpp

示例9: OnRead

bool_t SyncAcceptor::OnRead(EventResult *evr)
{
	bool_t ret = FALSE;

	SyncSession *sess = 0;

	ret = MakeEventHandler(sess);
	if(!ret) { ECILA_TRACE(); return FALSE; }

	ret = AcceptEventHandler(sess);
	if(!ret) { ECILA_TRACE(); goto _ERROR; }

	ret = ActivateEventHandler(sess);
	if(!ret) { ECILA_TRACE(); goto _ERROR; }

	return TRUE;

_ERROR:
	sess->OnClose(0);
	return FALSE;
}
开发者ID:ecilaz,项目名称:ecila,代码行数:21,代码来源:syncacceptor.cpp

示例10: handle_error

 bool handle_error(std::unique_lock<std::mutex>& lock, SyncSession& session, const SyncError& error) const override
 {
     if (error.is_fatal) {
         session.advance_state(lock, inactive);
     }
     // If the error isn't fatal, don't change state, but don't
     // allow it to be reported either.
     // FIXME: What if the token expires while a session is dying?
     // Should we allow the token to be refreshed so that changes
     // can finish being uploaded?
     return true;
 }
开发者ID:AlanAherne,项目名称:BabyTunes,代码行数:12,代码来源:sync_session.cpp

示例11: refresh_access_token

    void refresh_access_token(std::unique_lock<std::mutex>& lock, SyncSession& session,
                              std::string access_token,
                              const util::Optional<std::string>& server_url) const override
    {
        session.create_sync_session();

        // Since the sync session was previously unbound, it's safe to do this from the
        // calling thread.
        if (!session.m_server_url) {
            session.m_server_url = server_url;
        }
        if (session.m_session_has_been_bound) {
            session.m_session->refresh(std::move(access_token));
            session.m_session->cancel_reconnect_delay();
        } else {
            session.m_session->bind(*session.m_server_url, std::move(access_token));
            session.m_session_has_been_bound = true;
        }

        if (session.m_server_override)
            session.m_session->override_server(session.m_server_override->address, session.m_server_override->port);

        // Register all the pending wait-for-completion blocks.
        for (auto& package : session.m_completion_wait_packages) {
            (*session.m_session.*package.waiter)(std::move(package.callback));
        }
        session.m_completion_wait_packages.clear();

        // Handle any deferred commit notification.
        if (session.m_deferred_commit_notification) {
            session.m_session->nonsync_transact_notify(*session.m_deferred_commit_notification);
            session.m_deferred_commit_notification = util::none;
        }

        session.advance_state(lock, active);
        if (session.m_deferred_close) {
            session.m_state->close(lock, session);
        }
    }
开发者ID:AlanAherne,项目名称:BabyTunes,代码行数:39,代码来源:sync_session.cpp

示例12: close

 void close(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     switch (session.m_config.stop_policy) {
         case SyncSessionStopPolicy::Immediately:
             // Immediately kill the session.
             session.advance_state(lock, inactive);
             break;
         case SyncSessionStopPolicy::LiveIndefinitely:
         case SyncSessionStopPolicy::AfterChangesUploaded:
             // Defer handling closing the session until after the login response succeeds.
             session.m_deferred_close = true;
             break;
     }
 }
开发者ID:AlanAherne,项目名称:BabyTunes,代码行数:14,代码来源:sync_session.cpp

示例13: enter_state

    void enter_state(std::unique_lock<std::mutex>&, SyncSession& session) const override
    {
        ++session.m_pending_upload_threads;
        std::thread([session=&session] {
            std::unique_lock<std::mutex> lock(session->m_state_mutex);
            if (session->m_pending_upload_threads != 1) {
                --session->m_pending_upload_threads;
                return;
            }

            if (session->m_state != &State::dying) {
                // The session was revived. Don't kill it.
                --session->m_pending_upload_threads;
                return;
            }

            session->m_session->wait_for_upload_complete_or_client_stopped();
            --session->m_pending_upload_threads;
            session->advance_state(lock, inactive);
        }).detach();
    }
开发者ID:DenisDorokhov,项目名称:pony-ios,代码行数:21,代码来源:sync_session.cpp

示例14: handle_progress_update

 static void handle_progress_update(SyncSession& session, uint64_t downloaded, uint64_t downloadable,
                                    uint64_t uploaded, uint64_t uploadable, bool is_fresh=true) {
     session.handle_progress_update(downloaded, downloadable, uploaded, uploadable, is_fresh);
 }
开发者ID:FancyPixel,项目名称:gulps,代码行数:4,代码来源:sync_session.hpp

示例15: close_if_connecting

 void close_if_connecting(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     // Ignore the sync configuration's stop policy as we're not yet connected.
     session.advance_state(lock, inactive);
 }
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:5,代码来源:sync_session.cpp


注:本文中的SyncSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。