libfoedus-core
FOEDUS Core Library
foedus::xct::McsWwBlockData Struct Reference

Exclusive-only (WW) MCS lock classes. More...

Detailed Description

Exclusive-only (WW) MCS lock classes.

These are mainly used for page locks. Represents an exclusive-only MCS node, a pair of node-owner (thread) and its block index.

Definition at line 182 of file xct_id.hpp.

#include <xct_id.hpp>

Public Member Functions

 McsWwBlockData ()
 
 McsWwBlockData (uint64_t word)
 
 McsWwBlockData (uint32_t thread_id, McsBlockIndex block)
 
bool operator== (const McsWwBlockData &other) const
 
bool operator!= (const McsWwBlockData &other) const
 
uint64_t get_word_acquire () const __attribute__((always_inline))
 
uint64_t get_word_consume () const __attribute__((always_inline))
 
uint64_t get_word_atomic () const __attribute__((always_inline))
 
uint64_t get_word_once () const __attribute__((always_inline))
 The access_once semantics, which is widely used in linux. More...
 
McsWwBlockData copy_once () const __attribute__((always_inline))
 
McsWwBlockData copy_consume () const __attribute__((always_inline))
 
McsWwBlockData copy_acquire () const __attribute__((always_inline))
 
McsWwBlockData copy_atomic () const __attribute__((always_inline))
 
bool is_valid_relaxed () const __attribute__((always_inline))
 
bool is_valid_consume () const __attribute__((always_inline))
 
bool is_valid_acquire () const __attribute__((always_inline))
 
bool is_valid_atomic () const __attribute__((always_inline))
 
bool is_guest_relaxed () const __attribute__((always_inline))
 
bool is_guest_acquire () const __attribute__((always_inline))
 
bool is_guest_consume () const __attribute__((always_inline))
 
bool is_guest_atomic () const __attribute__((always_inline))
 
uint32_t get_thread_id_relaxed () const __attribute__((always_inline))
 Carefully use this! In some places you must call get_word_once() then call this on the copy. More...
 
McsBlockIndex get_block_relaxed () const __attribute__((always_inline))
 Carefully use this! In some places you must call get_word_once() then call this on the copy. More...
 
void clear () __attribute__((always_inline))
 
void clear_atomic () __attribute__((always_inline))
 
void clear_release () __attribute__((always_inline))
 
void set_relaxed (uint32_t thread_id, McsBlockIndex block) __attribute__((always_inline))
 
void set_atomic (uint32_t thread_id, McsBlockIndex block) __attribute__((always_inline))
 
void set_release (uint32_t thread_id, McsBlockIndex block) __attribute__((always_inline))
 
void set_combined_atomic (uint64_t word) __attribute__((always_inline))
 
void set_combined_release (uint64_t word) __attribute__((always_inline))
 

Static Public Member Functions

static uint64_t combine (uint32_t thread_id, McsBlockIndex block) __attribute__((always_inline))
 
static uint32_t decompose_thread_id (uint64_t word) __attribute__((always_inline))
 
static McsBlockIndex decompose_block (uint64_t word) __attribute__((always_inline))
 

Public Attributes

uint64_t word_
 The high 32-bits is thread_id, the low 32-bit is block-index. More...
 

Constructor & Destructor Documentation

foedus::xct::McsWwBlockData::McsWwBlockData ( )
inline

Definition at line 204 of file xct_id.hpp.

Referenced by copy_acquire(), copy_atomic(), copy_consume(), and copy_once().

204 : word_(0) {}
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

foedus::xct::McsWwBlockData::McsWwBlockData ( uint64_t  word)
inlineexplicit

Definition at line 205 of file xct_id.hpp.

205 : word_(word) {}
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189
foedus::xct::McsWwBlockData::McsWwBlockData ( uint32_t  thread_id,
McsBlockIndex  block 
)
inline

Definition at line 206 of file xct_id.hpp.

206 : word_(combine(thread_id, block)) {}
static uint64_t combine(uint32_t thread_id, McsBlockIndex block) __attribute__((always_inline))
Definition: xct_id.hpp:191
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Member Function Documentation

void foedus::xct::McsWwBlockData::clear ( )
inline

Definition at line 253 of file xct_id.hpp.

Referenced by foedus::xct::McsWwLock::McsWwLock(), and foedus::xct::McsWwLock::reset().

253 { word_ = 0; }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

void foedus::xct::McsWwBlockData::clear_atomic ( )
inline

Definition at line 254 of file xct_id.hpp.

References word_.

Referenced by foedus::xct::McsWwBlock::clear_successor_atomic().

254 { assorted::atomic_store_seq_cst<uint64_t>(&word_, 0); }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

void foedus::xct::McsWwBlockData::clear_release ( )
inline

Definition at line 255 of file xct_id.hpp.

References word_.

Referenced by foedus::xct::McsWwBlock::clear_successor_release().

255 { assorted::atomic_store_release<uint64_t>(&word_, 0); }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

static uint64_t foedus::xct::McsWwBlockData::combine ( uint32_t  thread_id,
McsBlockIndex  block 
)
inlinestatic

Definition at line 191 of file xct_id.hpp.

Referenced by set_atomic(), set_relaxed(), and set_release().

191  {
192  uint64_t word = thread_id;
193  word <<= 32;
194  word |= block;
195  return word;
196  }

Here is the caller graph for this function:

McsWwBlockData foedus::xct::McsWwBlockData::copy_acquire ( ) const
inline

Definition at line 227 of file xct_id.hpp.

References get_word_acquire(), and McsWwBlockData().

Referenced by foedus::xct::McsWwLock::get_tail_acquire().

227 { return McsWwBlockData(get_word_acquire()); }
uint64_t get_word_acquire() const __attribute__((always_inline))
Definition: xct_id.hpp:211

Here is the call graph for this function:

Here is the caller graph for this function:

McsWwBlockData foedus::xct::McsWwBlockData::copy_atomic ( ) const
inline

Definition at line 228 of file xct_id.hpp.

References get_word_atomic(), and McsWwBlockData().

Referenced by foedus::xct::McsWwLock::get_tail_atomic().

228 { return McsWwBlockData(get_word_atomic()); }
uint64_t get_word_atomic() const __attribute__((always_inline))
Definition: xct_id.hpp:217

Here is the call graph for this function:

Here is the caller graph for this function:

McsWwBlockData foedus::xct::McsWwBlockData::copy_consume ( ) const
inline

Definition at line 226 of file xct_id.hpp.

References get_word_consume(), and McsWwBlockData().

Referenced by foedus::xct::McsWwLock::get_tail_consume().

226 { return McsWwBlockData(get_word_consume()); }
uint64_t get_word_consume() const __attribute__((always_inline))
Definition: xct_id.hpp:214

Here is the call graph for this function:

Here is the caller graph for this function:

McsWwBlockData foedus::xct::McsWwBlockData::copy_once ( ) const
inline

Definition at line 225 of file xct_id.hpp.

References get_word_once(), and McsWwBlockData().

Referenced by foedus::xct::McsWwLock::get_tail_once().

225 { return McsWwBlockData(get_word_once()); }
uint64_t get_word_once() const __attribute__((always_inline))
The access_once semantics, which is widely used in linux.
Definition: xct_id.hpp:224

Here is the call graph for this function:

Here is the caller graph for this function:

static McsBlockIndex foedus::xct::McsWwBlockData::decompose_block ( uint64_t  word)
inlinestatic

Definition at line 200 of file xct_id.hpp.

Referenced by get_block_relaxed().

200  {
201  return static_cast<McsBlockIndex>(word & 0xFFFFFFFFUL);
202  }
uint32_t McsBlockIndex
Index in thread-local MCS block.
Definition: xct_id.hpp:153

Here is the caller graph for this function:

static uint32_t foedus::xct::McsWwBlockData::decompose_thread_id ( uint64_t  word)
inlinestatic

Definition at line 197 of file xct_id.hpp.

Referenced by get_thread_id_relaxed().

197  {
198  return static_cast<uint32_t>((word >> 32) & 0xFFFFFFFFUL);
199  }

Here is the caller graph for this function:

McsBlockIndex foedus::xct::McsWwBlockData::get_block_relaxed ( ) const
inline

Carefully use this! In some places you must call get_word_once() then call this on the copy.

We thus put "_relaxed" as suffix.

Definition at line 250 of file xct_id.hpp.

References decompose_block().

Referenced by foedus::xct::McsWwImpl< ADAPTOR >::acquire_unconditional(), foedus::xct::McsWwBlock::get_successor_block_relaxed(), and foedus::xct::McsWwLock::get_tail_waiter_block().

250  {
252  }
static McsBlockIndex decompose_block(uint64_t word) __attribute__((always_inline))
Definition: xct_id.hpp:200
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the call graph for this function:

Here is the caller graph for this function:

uint32_t foedus::xct::McsWwBlockData::get_thread_id_relaxed ( ) const
inline

Carefully use this! In some places you must call get_word_once() then call this on the copy.

We thus put "_relaxed" as suffix.

Definition at line 243 of file xct_id.hpp.

References decompose_thread_id().

Referenced by foedus::xct::McsWwImpl< ADAPTOR >::acquire_try(), foedus::xct::McsWwImpl< ADAPTOR >::acquire_unconditional(), foedus::xct::McsWwBlock::get_successor_thread_id_relaxed(), and foedus::xct::McsWwLock::get_tail_waiter().

243  {
245  }
static uint32_t decompose_thread_id(uint64_t word) __attribute__((always_inline))
Definition: xct_id.hpp:197
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t foedus::xct::McsWwBlockData::get_word_acquire ( ) const
inline

Definition at line 211 of file xct_id.hpp.

References word_.

Referenced by copy_acquire(), is_guest_acquire(), and is_valid_acquire().

211  {
212  return assorted::atomic_load_acquire<uint64_t>(&word_);
213  }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

uint64_t foedus::xct::McsWwBlockData::get_word_atomic ( ) const
inline

Definition at line 217 of file xct_id.hpp.

References word_.

Referenced by copy_atomic(), is_guest_atomic(), and is_valid_atomic().

217  {
218  return assorted::atomic_load_seq_cst<uint64_t>(&word_);
219  }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

uint64_t foedus::xct::McsWwBlockData::get_word_consume ( ) const
inline

Definition at line 214 of file xct_id.hpp.

References word_.

Referenced by copy_consume(), is_guest_consume(), and is_valid_consume().

214  {
215  return assorted::atomic_load_consume<uint64_t>(&word_);
216  }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

uint64_t foedus::xct::McsWwBlockData::get_word_once ( ) const
inline

The access_once semantics, which is widely used in linux.

This is weaker than get_word_atomic(), but enough for many places.

Definition at line 224 of file xct_id.hpp.

References word_.

Referenced by copy_once().

224 { return *(&word_); }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

bool foedus::xct::McsWwBlockData::is_guest_acquire ( ) const
inline

Definition at line 236 of file xct_id.hpp.

References get_word_acquire(), and foedus::xct::kMcsGuestId.

236 { return get_word_acquire() == kMcsGuestId; }
uint64_t get_word_acquire() const __attribute__((always_inline))
Definition: xct_id.hpp:211
const uint64_t kMcsGuestId
A special value meaning the lock is held by a non-regular guest that doesn't have a context...
Definition: xct_id.hpp:158

Here is the call graph for this function:

bool foedus::xct::McsWwBlockData::is_guest_atomic ( ) const
inline

Definition at line 238 of file xct_id.hpp.

References get_word_atomic(), and foedus::xct::kMcsGuestId.

238 { return get_word_atomic() == kMcsGuestId; }
uint64_t get_word_atomic() const __attribute__((always_inline))
Definition: xct_id.hpp:217
const uint64_t kMcsGuestId
A special value meaning the lock is held by a non-regular guest that doesn't have a context...
Definition: xct_id.hpp:158

Here is the call graph for this function:

bool foedus::xct::McsWwBlockData::is_guest_consume ( ) const
inline

Definition at line 237 of file xct_id.hpp.

References get_word_consume(), and foedus::xct::kMcsGuestId.

237 { return get_word_consume() == kMcsGuestId; }
uint64_t get_word_consume() const __attribute__((always_inline))
Definition: xct_id.hpp:214
const uint64_t kMcsGuestId
A special value meaning the lock is held by a non-regular guest that doesn't have a context...
Definition: xct_id.hpp:158

Here is the call graph for this function:

bool foedus::xct::McsWwBlockData::is_guest_relaxed ( ) const
inline

Definition at line 235 of file xct_id.hpp.

References foedus::xct::kMcsGuestId.

Referenced by foedus::xct::McsWwImpl< ADAPTOR >::acquire_try(), foedus::xct::McsWwImpl< ADAPTOR >::acquire_unconditional(), foedus::xct::McsWwOwnerlessImpl::ownerless_release(), and foedus::xct::McsWwImpl< ADAPTOR >::release().

235 { return word_ == kMcsGuestId; }
const uint64_t kMcsGuestId
A special value meaning the lock is held by a non-regular guest that doesn't have a context...
Definition: xct_id.hpp:158
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

bool foedus::xct::McsWwBlockData::is_valid_acquire ( ) const
inline

Definition at line 232 of file xct_id.hpp.

References get_word_acquire().

Referenced by foedus::xct::McsWwBlock::has_successor_acquire().

232 { return get_word_acquire() != 0; }
uint64_t get_word_acquire() const __attribute__((always_inline))
Definition: xct_id.hpp:211

Here is the call graph for this function:

Here is the caller graph for this function:

bool foedus::xct::McsWwBlockData::is_valid_atomic ( ) const
inline

Definition at line 233 of file xct_id.hpp.

References get_word_atomic().

Referenced by foedus::xct::McsWwBlock::has_successor_atomic().

233 { return get_word_atomic() != 0; }
uint64_t get_word_atomic() const __attribute__((always_inline))
Definition: xct_id.hpp:217

Here is the call graph for this function:

Here is the caller graph for this function:

bool foedus::xct::McsWwBlockData::is_valid_consume ( ) const
inline

Definition at line 231 of file xct_id.hpp.

References get_word_consume().

Referenced by foedus::xct::McsWwBlock::has_successor_consume().

231 { return get_word_consume() != 0; }
uint64_t get_word_consume() const __attribute__((always_inline))
Definition: xct_id.hpp:214

Here is the call graph for this function:

Here is the caller graph for this function:

bool foedus::xct::McsWwBlockData::operator!= ( const McsWwBlockData other) const
inline

Definition at line 209 of file xct_id.hpp.

References word_.

209 { return word_ != other.word_; }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189
bool foedus::xct::McsWwBlockData::operator== ( const McsWwBlockData other) const
inline

Definition at line 208 of file xct_id.hpp.

References word_.

208 { return word_ == other.word_; }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189
void foedus::xct::McsWwBlockData::set_atomic ( uint32_t  thread_id,
McsBlockIndex  block 
)
inline

Definition at line 259 of file xct_id.hpp.

References combine(), and set_combined_atomic().

Referenced by foedus::xct::McsWwLock::reset_atomic(), and foedus::xct::McsWwBlock::set_successor_atomic().

259  {
260  set_combined_atomic(McsWwBlockData::combine(thread_id, block));
261  }
static uint64_t combine(uint32_t thread_id, McsBlockIndex block) __attribute__((always_inline))
Definition: xct_id.hpp:191
void set_combined_atomic(uint64_t word) __attribute__((always_inline))
Definition: xct_id.hpp:265

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::xct::McsWwBlockData::set_combined_atomic ( uint64_t  word)
inline

Definition at line 265 of file xct_id.hpp.

References word_.

Referenced by set_atomic().

265  {
266  assorted::atomic_store_seq_cst<uint64_t>(&word_, word);
267  }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

void foedus::xct::McsWwBlockData::set_combined_release ( uint64_t  word)
inline

Definition at line 268 of file xct_id.hpp.

References word_.

Referenced by foedus::xct::McsWwLock::reset_guest_id_release(), and set_release().

268  {
269  assorted::atomic_store_release<uint64_t>(&word_, word);
270  }
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the caller graph for this function:

void foedus::xct::McsWwBlockData::set_relaxed ( uint32_t  thread_id,
McsBlockIndex  block 
)
inline

Definition at line 256 of file xct_id.hpp.

References combine().

Referenced by foedus::xct::McsWwLock::McsWwLock(), and foedus::xct::McsWwLock::reset().

256  {
257  word_ = McsWwBlockData::combine(thread_id, block);
258  }
static uint64_t combine(uint32_t thread_id, McsBlockIndex block) __attribute__((always_inline))
Definition: xct_id.hpp:191
uint64_t word_
The high 32-bits is thread_id, the low 32-bit is block-index.
Definition: xct_id.hpp:189

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::xct::McsWwBlockData::set_release ( uint32_t  thread_id,
McsBlockIndex  block 
)
inline

Definition at line 262 of file xct_id.hpp.

References combine(), and set_combined_release().

Referenced by foedus::xct::McsWwLock::reset_release(), and foedus::xct::McsWwBlock::set_successor_release().

262  {
264  }
static uint64_t combine(uint32_t thread_id, McsBlockIndex block) __attribute__((always_inline))
Definition: xct_id.hpp:191
void set_combined_release(uint64_t word) __attribute__((always_inline))
Definition: xct_id.hpp:268

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

uint64_t foedus::xct::McsWwBlockData::word_

The high 32-bits is thread_id, the low 32-bit is block-index.

We so far need only 16-bits each, but reserved more bits for future use. We previously used union for this, but it caused many "accidentally non-access-once" bugs. We thus avoid using union. Not saying that union is wrong, but it's prone to such coding.

Definition at line 189 of file xct_id.hpp.

Referenced by foedus::xct::McsWwImpl< ADAPTOR >::acquire_try(), foedus::xct::McsWwImpl< ADAPTOR >::acquire_unconditional(), clear_atomic(), clear_release(), get_word_acquire(), get_word_atomic(), get_word_consume(), get_word_once(), operator!=(), operator==(), foedus::xct::McsWwOwnerlessImpl::ownerless_acquire_try(), foedus::xct::McsWwOwnerlessImpl::ownerless_acquire_unconditional(), foedus::xct::McsWwOwnerlessImpl::ownerless_release(), foedus::xct::McsWwImpl< ADAPTOR >::release(), set_combined_atomic(), and set_combined_release().


The documentation for this struct was generated from the following file: