libfoedus-core
FOEDUS Core Library
impersonate_session.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
18 #ifndef FOEDUS_THREAD_IMPERSONATE_SESSION_HPP_
19 #define FOEDUS_THREAD_IMPERSONATE_SESSION_HPP_
20 #include <iosfwd>
21 
22 #include "foedus/cxx11.hpp"
23 #include "foedus/error_stack.hpp"
24 #include "foedus/thread/fwd.hpp"
25 
26 namespace foedus {
27 namespace thread {
64 
65  // Not copy-able
68 
69 #ifndef DISABLE_CXX11_IN_PUBLIC_HEADERS
70  // but move-able (only in C++11)
73 #endif // DISABLE_CXX11_IN_PUBLIC_HEADERS
74 
78  bool is_valid() const { return thread_ != CXX11_NULLPTR && ticket_ != 0; }
80  bool is_running() const;
81 
91  uint64_t get_output_size();
95  void get_output(void* output_buffer);
97  const void* get_raw_output_buffer();
98 
107  void wait() const;
108 
119  bool wait_for(uint64_t timeout_microsec) const;
120 
131  void release();
132 
133  friend std::ostream& operator<<(std::ostream& o, const ImpersonateSession& v);
134 
137 
140 };
141 } // namespace thread
142 } // namespace foedus
143 #endif // FOEDUS_THREAD_IMPERSONATE_SESSION_HPP_
void release()
Releases all resources and ownerships this session has acquired.
ErrorStack get_result()
Waits until the completion of the asynchronous session and retrieves the result.
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
thread::ThreadRef * thread_
The impersonated thread.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
uint64_t get_output_size()
Returns the byte size of output.
void wait() const
Blocks until the completion of the asynchronous session.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
thread::ThreadTicket ticket_
The ticket issued as of impersonation.
A user session running on an impersonated thread.
bool is_running() const
Returns if the task is still running.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
const void * get_raw_output_buffer()
Returns the pointer to the raw output buffer on shared memory.
bool is_valid() const
Returns if the impersonation succeeded.
void get_output(void *output_buffer)
Copies the output to the given buffer, whose size must be at least get_output_size().
A view of Thread object for other SOCs and master engine.
Definition: thread_ref.hpp:39
bool wait_for(uint64_t timeout_microsec) const
Blocks until either the asynchronous session completes or the specified time elapses.
ImpersonateSession & operator=(const ImpersonateSession &other)=delete
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128
friend std::ostream & operator<<(std::ostream &o, const ImpersonateSession &v)
Forward declarations of classes in thread package.
uint64_t ThreadTicket
Typedef for a monotonically increasing ticket for thread impersonation.
Definition: thread_id.hpp:117