libfoedus-core
FOEDUS Core Library
|
A user session running on an impersonated thread. More...
A user session running on an impersonated thread.
Definition at line 61 of file impersonate_session.hpp.
#include <impersonate_session.hpp>
Public Member Functions | |
ImpersonateSession () | |
~ImpersonateSession () | |
ImpersonateSession (const ImpersonateSession &other)=delete | |
ImpersonateSession & | operator= (const ImpersonateSession &other)=delete |
ImpersonateSession (ImpersonateSession &&other) | |
ImpersonateSession & | operator= (ImpersonateSession &&other) |
bool | is_valid () const |
Returns if the impersonation succeeded. More... | |
bool | is_running () const |
Returns if the task is still running. More... | |
ErrorStack | get_result () |
Waits until the completion of the asynchronous session and retrieves the result. More... | |
uint64_t | get_output_size () |
Returns the byte size of output. More... | |
void | get_output (void *output_buffer) |
Copies the output to the given buffer, whose size must be at least get_output_size(). More... | |
const void * | get_raw_output_buffer () |
Returns the pointer to the raw output buffer on shared memory. More... | |
void | wait () const |
Blocks until the completion of the asynchronous session. More... | |
bool | wait_for (uint64_t timeout_microsec) const |
Blocks until either the asynchronous session completes or the specified time elapses. More... | |
void | release () |
Releases all resources and ownerships this session has acquired. More... | |
Public Attributes | |
thread::ThreadRef * | thread_ |
The impersonated thread. More... | |
thread::ThreadTicket | ticket_ |
The ticket issued as of impersonation. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const ImpersonateSession &v) |
|
inline |
Definition at line 62 of file impersonate_session.hpp.
|
inline |
Definition at line 63 of file impersonate_session.hpp.
References release().
|
delete |
foedus::thread::ImpersonateSession::ImpersonateSession | ( | ImpersonateSession && | other | ) |
Definition at line 30 of file impersonate_session.cpp.
References thread_, and ticket_.
void foedus::thread::ImpersonateSession::get_output | ( | void * | output_buffer | ) |
Copies the output to the given buffer, whose size must be at least get_output_size().
Definition at line 58 of file impersonate_session.cpp.
References get_output_size(), foedus::thread::ThreadRef::get_task_output_memory(), and thread_.
uint64_t foedus::thread::ImpersonateSession::get_output_size | ( | ) |
Returns the byte size of output.
Definition at line 65 of file impersonate_session.cpp.
References foedus::thread::ThreadRef::get_control_block(), foedus::thread::ThreadControlBlock::output_len_, and thread_.
Referenced by get_output().
const void * foedus::thread::ImpersonateSession::get_raw_output_buffer | ( | ) |
Returns the pointer to the raw output buffer on shared memory.
Definition at line 61 of file impersonate_session.cpp.
References foedus::thread::ThreadRef::get_task_output_memory(), and thread_.
ErrorStack foedus::thread::ImpersonateSession::get_result | ( | ) |
Waits until the completion of the asynchronous session and retrieves the result.
It effectively calls wait() in order to wait for the result. The behavior is undefined if is_valid()== false.
Definition at line 46 of file impersonate_session.cpp.
References foedus::thread::ThreadControlBlock::current_ticket_, ERROR_STACK, foedus::thread::ThreadRef::get_control_block(), is_valid(), foedus::kErrorCodeSessionExpired, foedus::thread::kWaitingForClientRelease, foedus::thread::ThreadControlBlock::proc_result_, foedus::thread::ThreadControlBlock::status_, thread_, ticket_, foedus::FixedErrorStack::to_error_stack(), and wait().
Referenced by foedus::thread::ThreadPool::impersonate_on_numa_core_synchronous(), foedus::thread::ThreadPool::impersonate_on_numa_node_synchronous(), and foedus::thread::ThreadPool::impersonate_synchronous().
bool foedus::thread::ImpersonateSession::is_running | ( | ) | const |
Returns if the task is still running.
Definition at line 105 of file impersonate_session.cpp.
References ASSERT_ND, foedus::thread::ThreadControlBlock::current_ticket_, foedus::thread::ThreadRef::get_control_block(), foedus::thread::kRunningTask, foedus::thread::kWaitingForExecution, foedus::thread::ThreadControlBlock::status_, thread_, and ticket_.
Referenced by wait(), and wait_for().
|
inline |
Returns if the impersonation succeeded.
Definition at line 78 of file impersonate_session.hpp.
References CXX11_NULLPTR, thread_, and ticket_.
Referenced by get_result(), foedus::thread::operator<<(), release(), foedus::thread::ThreadRef::try_impersonate(), wait(), and wait_for().
|
delete |
ImpersonateSession & foedus::thread::ImpersonateSession::operator= | ( | ImpersonateSession && | other | ) |
Definition at line 37 of file impersonate_session.cpp.
References thread_, and ticket_.
void foedus::thread::ImpersonateSession::release | ( | ) |
Releases all resources and ownerships this session has acquired.
This method is idempotent, you can call it in any state and many times. Actually, this is also called from the destructor. This method might block if the session is still running. We do not allow the user to discard this session without completing the currently running task.
Definition at line 114 of file impersonate_session.cpp.
References foedus::thread::ThreadControlBlock::current_ticket_, foedus::thread::ThreadRef::get_control_block(), is_valid(), foedus::thread::kWaitingForClientRelease, foedus::thread::kWaitingForTask, foedus::thread::ThreadControlBlock::status_, thread_, ticket_, and wait().
Referenced by foedus::thread::ThreadRef::try_impersonate(), and ~ImpersonateSession().
void foedus::thread::ImpersonateSession::wait | ( | ) | const |
Blocks until the completion of the asynchronous session.
The behavior is undefined if is_valid()== false. It effectively calls wait_for(-1) in order to unconditionally wait for the result. This is analogous to std::future::wait().
Definition at line 69 of file impersonate_session.cpp.
References foedus::soc::SharedPolling::acquire_ticket(), foedus::thread::ThreadRef::get_control_block(), is_running(), is_valid(), foedus::thread::ThreadControlBlock::task_complete_cond_, thread_, and foedus::soc::SharedPolling::timedwait().
Referenced by get_result(), and release().
bool foedus::thread::ImpersonateSession::wait_for | ( | uint64_t | timeout_microsec | ) | const |
Blocks until either the asynchronous session completes or the specified time elapses.
[in] | timeout_microsec | timeout in microsec. 0 means an instant check without waiting. |
The behavior is undefined if is_valid()== false. It effectively calls wait_for(timeout) in order to conditionally wait for the result. This is analogous to std::future::wait_for().
Definition at line 83 of file impersonate_session.cpp.
References foedus::soc::SharedPolling::acquire_ticket(), foedus::thread::ThreadRef::get_control_block(), is_running(), is_valid(), foedus::thread::ThreadControlBlock::task_complete_cond_, thread_, and foedus::soc::SharedPolling::timedwait().
|
friend |
Definition at line 130 of file impersonate_session.cpp.
thread::ThreadRef* foedus::thread::ImpersonateSession::thread_ |
The impersonated thread.
If impersonation failed, null.
Definition at line 136 of file impersonate_session.hpp.
Referenced by get_output(), get_output_size(), get_raw_output_buffer(), get_result(), ImpersonateSession(), is_running(), is_valid(), foedus::thread::operator<<(), operator=(), release(), foedus::thread::ThreadRef::try_impersonate(), wait(), and wait_for().
thread::ThreadTicket foedus::thread::ImpersonateSession::ticket_ |
The ticket issued as of impersonation.
If impersonation failed, 0.
Definition at line 139 of file impersonate_session.hpp.
Referenced by get_result(), ImpersonateSession(), is_running(), is_valid(), operator=(), release(), and foedus::thread::ThreadRef::try_impersonate().