libfoedus-core
FOEDUS Core Library
xct_access.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_ACCESS_HPP_
19 #define FOEDUS_XCT_XCT_ACCESS_HPP_
20 #include <stdint.h>
21 
22 #include <iosfwd>
23 
24 #include "foedus/compiler.hpp"
25 #include "foedus/log/fwd.hpp"
26 #include "foedus/memory/fwd.hpp"
27 #include "foedus/storage/fwd.hpp"
28 #include "foedus/storage/page.hpp"
30 #include "foedus/xct/fwd.hpp"
31 #include "foedus/xct/xct_id.hpp"
32 
33 namespace foedus {
34 namespace xct {
35 
48 struct PointerAccess {
49  friend std::ostream& operator<<(std::ostream& o, const PointerAccess& v);
50 
53 
56 };
57 
73  friend std::ostream& operator<<(std::ostream& o, const PageVersionAccess& v);
74 
77 
80 };
81 
86 
96  uint32_t ordinal_;
97 
103 
106 
111  void set_owner_id_and_lock_id(RwLockableXctId* owner_id_address, UniversalLockId owner_lock_id) {
112  owner_id_address_ = owner_id_address;
113  owner_lock_id_ = owner_lock_id;
114  }
120  const memory::GlobalVolatilePageResolver& resolver,
121  RwLockableXctId* owner_id_address);
122 
129  static bool compare(const RecordXctAccess &left, const RecordXctAccess& right) ALWAYS_INLINE;
130 };
131 
140  friend std::ostream& operator<<(std::ostream& o, const ReadXctAccess& v);
141 
144 
154 
156  static bool compare(const ReadXctAccess &left, const ReadXctAccess& right) ALWAYS_INLINE {
157  return RecordXctAccess::compare(left, right);
158  }
159 };
160 
169  friend std::ostream& operator<<(std::ostream& o, const WriteXctAccess& v);
170 
173 
176 
179 
181  static bool compare(const WriteXctAccess &left, const WriteXctAccess& right) ALWAYS_INLINE {
182  return RecordXctAccess::compare(left, right);
183  }
184 };
185 
201  friend std::ostream& operator<<(std::ostream& o, const LockFreeReadXctAccess& v);
202 
205 
208 
211 
212  // no related-write in this object.
213  // also, no sorting needed for this object.
214 };
215 
229  friend std::ostream& operator<<(std::ostream& o, const LockFreeWriteXctAccess& v);
230 
233 
236 
237  // no need for compare method or storing version/record/etc. it's lock-free!
238 };
239 
241  const RecordXctAccess& left,
242  const RecordXctAccess& right) {
243  if (left.owner_lock_id_ != right.owner_lock_id_) {
244  return left.owner_lock_id_ < right.owner_lock_id_;
245  } else {
246  return left.ordinal_ < right.ordinal_;
247  }
248 }
249 
250 } // namespace xct
251 } // namespace foedus
252 #endif // FOEDUS_XCT_XCT_ACCESS_HPP_
friend std::ostream & operator<<(std::ostream &o, const LockFreeReadXctAccess &v)
Definition: xct_access.cpp:75
ReadXctAccess * related_read_
Definition: xct_access.hpp:178
log::RecordLogType * log_entry_
Pointer to the log entry in private log buffer for this write opereation.
Definition: xct_access.hpp:175
RwLockableXctId * owner_id_address_
Pointer to the TID we protect against.
Definition: xct_access.hpp:210
Represents a record of special read-access during a transaction without any need for locking...
Definition: xct_access.hpp:200
const storage::PageVersion * address_
Address to the page version.
Definition: xct_access.hpp:76
Definitions of IDs in this package and a few related constant values.
Forward declarations of classes in log manager package.
uint32_t StorageId
Unique ID for storage.
Definition: storage_id.hpp:55
uint32_t ordinal_
Indicates the ordinal among ReadXctAccess/WriteXctAccess of this transaction.
Definition: xct_access.hpp:96
XctId observed_owner_id_
Transaction ID of the record observed as of the access.
Definition: xct_access.hpp:143
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
Represents a record of write-access during a transaction.
Definition: xct_access.hpp:168
const storage::VolatilePagePointer * address_
Address of the volatile pointer.
Definition: xct_access.hpp:52
storage::VolatilePagePointer observed_
Value of the volatile pointer as of the access.
Definition: xct_access.hpp:55
friend std::ostream & operator<<(std::ostream &o, const ReadXctAccess &v)
Definition: xct_access.cpp:44
Forward declarations of classes in transaction package.
Represents a pointer to a volatile page with modification count for preventing ABA.
Definition: storage_id.hpp:194
Just a synonym of XctId to be used as a page lock mechanism.
Definition: page.hpp:129
storage::PageVersionStatus observed_
Value of the page version as of the access.
Definition: xct_access.hpp:79
Persistent status part of Transaction ID.
Definition: xct_id.hpp:955
Represents a record of read-access during a transaction.
Definition: xct_access.hpp:139
static bool compare(const RecordXctAccess &left, const RecordXctAccess &right) __attribute__((always_inline))
sort the write set in a unique order.
Definition: xct_access.hpp:240
Represents a record of special write-access during a transaction without any need for locking...
Definition: xct_access.hpp:228
XctId observed_owner_id_
XID value we observed.
Definition: xct_access.hpp:204
uintptr_t UniversalLockId
Universally ordered identifier of each lock.
Definition: xct_id.hpp:134
The MCS reader-writer lock variant of LockableXctId.
Definition: xct_id.hpp:1132
storage::StorageId storage_id_
The storage we accessed.
Definition: xct_access.hpp:207
Forward declarations of classes in storage package.
static bool compare(const WriteXctAccess &left, const WriteXctAccess &right) __attribute__((always_inline))
Definition: xct_access.hpp:181
Definitions of IDs in this package and a few related constant values.
void set_owner_id_resolve_lock_id(const memory::GlobalVolatilePageResolver &resolver, RwLockableXctId *owner_id_address)
Calculate owner_lock_id using the resolver.
Definition: xct_access.cpp:93
friend std::ostream & operator<<(std::ostream &o, const WriteXctAccess &v)
Definition: xct_access.cpp:59
RwLockableXctId * owner_id_address_
Pointer to the accessed record.
Definition: xct_access.hpp:102
char * payload_address_
Pointer to the payload of the record.
Definition: xct_access.hpp:172
storage::StorageId storage_id_
The storage we accessed.
Definition: xct_access.hpp:85
WriteXctAccess * related_write_
An optional member that points to a write access related to this read.
Definition: xct_access.hpp:153
Forward declarations of classes in memory package.
friend std::ostream & operator<<(std::ostream &o, const LockFreeWriteXctAccess &v)
Definition: xct_access.cpp:85
Resolves an offset in a volatile page pool to an actual pointer and vice versa.
friend std::ostream & operator<<(std::ostream &o, const PageVersionAccess &v)
Definition: xct_access.cpp:38
Base of ReadXctAccess and WriteXctAccess.
Definition: xct_access.hpp:83
log::RecordLogType * log_entry_
Pointer to the log entry in private log buffer for this write opereation.
Definition: xct_access.hpp:235
Base class for log type of record-wise operation.
Represents a record of following a page pointer during a transaction.
Definition: xct_access.hpp:48
UniversalLockId owner_lock_id_
Universal Lock ID of the lock in the record.
Definition: xct_access.hpp:105
#define ALWAYS_INLINE
A function suffix to hint that the function should always be inlined.
Definition: compiler.hpp:106
Represents a record of reading a page during a transaction.
Definition: xct_access.hpp:72
friend std::ostream & operator<<(std::ostream &o, const PointerAccess &v)
Definition: xct_access.cpp:32
void set_owner_id_and_lock_id(RwLockableXctId *owner_id_address, UniversalLockId owner_lock_id)
Setter for owner_id_address_/owner_lock_id_.
Definition: xct_access.hpp:111
static bool compare(const ReadXctAccess &left, const ReadXctAccess &right) __attribute__((always_inline))
Definition: xct_access.hpp:156
storage::StorageId storage_id_
The storage we accessed.
Definition: xct_access.hpp:232