libfoedus-core
FOEDUS Core Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
xct_manager.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_XCT_XCT_MANAGER_HPP_
19 #define FOEDUS_XCT_XCT_MANAGER_HPP_
20 #include "foedus/fwd.hpp"
21 #include "foedus/initializable.hpp"
22 #include "foedus/thread/fwd.hpp"
23 #include "foedus/xct/fwd.hpp"
24 #include "foedus/xct/xct_id.hpp"
25 namespace foedus {
26 namespace xct {
35 class XctManager CXX11_FINAL : public virtual Initializable {
36  public:
37  explicit XctManager(Engine* engine);
38  ~XctManager();
39 
40  // Disable default constructors
44 
46  bool is_initialized() const CXX11_OVERRIDE;
48 
54 
61 
63  void wait_for_current_global_epoch(Epoch target_epoch, int64_t wait_microseconds = -1);
64 
73 
80  ErrorCode begin_xct(thread::Thread* context, IsolationLevel isolation_level);
81 
98  ErrorCode precommit_xct(thread::Thread* context, Epoch *commit_epoch);
99 
100 
104  ErrorCode wait_for_commit(Epoch commit_epoch, int64_t wait_microseconds = -1);
105 
112 
114  void pause_accepting_xct();
116  void resume_accepting_xct();
117 
118  private:
119  XctManagerPimpl *pimpl_;
120 };
121 } // namespace xct
122 } // namespace foedus
123 #endif // FOEDUS_XCT_XCT_MANAGER_HPP_
Epoch get_current_global_epoch_weak() const
The pure-virtual interface to initialize/uninitialize non-trivial resources.
Epoch get_current_global_epoch() const
Returns the current global epoch, the epoch a newly started transaction will be in.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
bool is_initialized() const override
Returns whether the object has been already initialized or not.
Definition: xct_manager.cpp:31
Represents one thread running on one NUMA core.
Definition: thread.hpp:48
Epoch get_current_grace_epoch() const
Returns the current grace-period epoch (global epoch - 1), the epoch some transaction might be still ...
Epoch get_current_grace_epoch_weak() const
Forward declarations of classes in transaction package.
ErrorCode begin_xct(thread::Thread *context, IsolationLevel isolation_level)
Begins a new transaction on the thread.
void resume_accepting_xct()
Make sure you call this after pause_accepting_xct().
Definition: xct_manager.cpp:34
Forward declarations of classes in root package.
Brings error stacktrace information as return value of functions.
Definition: error_stack.hpp:81
Represents a time epoch.
Definition: epoch.hpp:61
void pause_accepting_xct()
Pause all begin_xct until you call resume_accepting_xct()
Definition: xct_manager.cpp:33
ErrorStack initialize() override
Acquires resources in this object, usually called right after constructor.
Definition: xct_manager.cpp:30
ErrorCode precommit_xct(thread::Thread *context, Epoch *commit_epoch)
Prepares the currently running transaction on the thread for commit.
Definitions of IDs in this package and a few related constant values.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
Database engine object that holds all resources and provides APIs.
Definition: engine.hpp:109
ErrorStack uninitialize() override
An idempotent method to release all resources of this object, if any.
Definition: xct_manager.cpp:32
ErrorCode abort_xct(thread::Thread *context)
Aborts the currently running transaction on the thread.
Xct Manager class that provides API to begin/abort/commit transaction.
Definition: xct_manager.hpp:35
#define CXX11_OVERRIDE
Used in public headers in place of "override" of C++11.
Definition: cxx11.hpp:134
void wait_for_current_global_epoch(Epoch target_epoch, int64_t wait_microseconds=-1)
Passively wait until the current global epoch becomes the given value.
Definition: xct_manager.cpp:35
IsolationLevel
Specifies the level of isolation during transaction processing.
Definition: xct_id.hpp:55
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128
void advance_current_global_epoch()
Requests to advance the current global epoch as soon as possible and blocks until it actually does...
Pimpl object of XctManager.
XctManager & operator=(const XctManager &)=delete
ErrorCode wait_for_commit(Epoch commit_epoch, int64_t wait_microseconds=-1)
Synchronously blocks until the durable global epoch reaches the given commit epoch or the given durat...
Forward declarations of classes in thread package.
ErrorCode
Enum of error codes defined in error_code.xmacro.
Definition: error_code.hpp:85