本文整理汇总了C++中SyncSession::shared_from_this方法的典型用法代码示例。如果您正苦于以下问题:C++ SyncSession::shared_from_this方法的具体用法?C++ SyncSession::shared_from_this怎么用?C++ SyncSession::shared_from_this使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyncSession
的用法示例。
在下文中一共展示了SyncSession::shared_from_this方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例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;
}
示例3: enter_state
void enter_state(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
{
// If we have no session, we cannot possibly upload anything.
if (!session.m_session) {
session.advance_state(lock, inactive);
return;
}
size_t current_death_count = ++session.m_death_count;
std::weak_ptr<SyncSession> weak_session = session.shared_from_this();
session.m_session->async_wait_for_upload_completion([weak_session, current_death_count](std::error_code) {
if (auto session = weak_session.lock()) {
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);
}
}
});
}