Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
Transactional::Transaction< XN > Class Template Reference

A class supporting transactional writing for a subtree.
See Brief introduction of software transactional memory using the class Node for basic ideas of this STM and code examples.
. More...

#include <transaction.h>

Inheritance diagram for Transactional::Transaction< XN >:
Inheritance graph
[legend]

Public Member Functions

 Transaction (Node< XN > &node, bool multi_nodal=true)
 
 Transaction (const Snapshot< XN > &x, bool multi_nodal=true) noexcept
 
 Transaction (Transaction &&x) noexcept=default
 
template<class T >
T::Payload & operator[] (const shared_ptr< T > &node)
 
template<class T >
T::Payload & operator[] (T &node)
 
bool isMultiNodal () const noexcept
 
template<typename T , typename... Args>
void mark (T &talker, Args &&...args)
 Reserves an event, to be emitted from talker with arg after the transaction is committed.
 
int unmark (const shared_ptr< XListener > &x)
 
bool isModified () const noexcept
 
bool commit ()
 
bool commitOrNext ()
 Combination of commit() and operator++().
 
Snapshot< XN > newTransactionUsingSnapshotFor (Node< XN > &supernode)
 
 Transaction (const Transaction &tr)=delete
 
Transactionoperator= (const Transaction &tr)=delete
 
- Public Member Functions inherited from Transactional::Snapshot< XN >
 Snapshot (const Snapshot &x) noexcept=default
 
 Snapshot (Snapshot &&x) noexcept=default
 
 Snapshot (Node< XN > &node, const Snapshot &x) noexcept
 
 Snapshot (const Transaction< XN > &x) noexcept
 
 Snapshot (Transaction< XN > &&x) noexcept
 
Snapshotoperator= (const Snapshot &x) noexcept=default
 
 Snapshot (const Node< XN > &node, bool multi_nodal=true)
 
template<class T >
const T::Payload & operator[] (const shared_ptr< T > &node) const noexcept
 
template<class T >
const T::Payload & operator[] (const T &node) const noexcept
 
int size () const noexcept
 

of child nodes.


 
const shared_ptr< const
typename Node< XN >::NodeList > 
list () const noexcept
 The list of child nodes.
 
int size (const shared_ptr< Node< XN > > &node) const noexcept
 

of child nodes owned by node.


 
shared_ptr< const typename
Node< XN >::NodeList > 
list (const shared_ptr< Node< XN > > &node) const noexcept
 The list of child nodes owned by node.
 
bool isUpperOf (const XN &lower) const noexcept
 Whether lower is a child of this or not.
 
void print ()
 
template<typename T , typename tArgRef >
void talk (T &talker, tArgRef arg) const
 Stores an event immediately from talker with arg.
 

Private Types

using MessageList = fast_vector< shared_ptr< Message_< Snapshot< XN >> >, 3 >
 

Private Member Functions

Transactionoperator++ ()
 Takes another snapshot and prepares for a next transaction.
 
void finalizeCommitment (Node< XN > &node)
 

Private Attributes

local_shared_ptr< typename
Node< XN >::Packet > 
m_oldpacket
 
const bool m_multi_nodal
 
Node< XN >
::NegotiationCounter::cnt_t 
m_started_time
 
unique_ptr< MessageListm_messages
 

Friends

class Node< XN >
 

Additional Inherited Members

- Protected Attributes inherited from Transactional::Snapshot< XN >
local_shared_ptr< typename
Node< XN >::Packet > 
m_packet
 The snapshot.
 
int64_t m_serial
 

Detailed Description

template<class XN>
class Transactional::Transaction< XN >

A class supporting transactional writing for a subtree.
See Brief introduction of software transactional memory using the class Node for basic ideas of this STM and code examples.
.

Transaction inherits features of Snapshot. Do something like the following to avoid a copy-on-write due to Transaction::operator[]():

const Snapshot<NodeA> &shot(transaction_A);
double x = shot[chidnode].m_x; //reading a value of m_x stored in transaction_A.
See Also
Node, Snapshot, SingleSnapshot, SingleTransaction.

Definition at line 544 of file transaction.h.

Constructor & Destructor Documentation

template<class XN>
Transactional::Transaction< XN >::Transaction ( Node< XN > &  node,
bool  multi_nodal = true 
)
inlineexplicit

Be sure for the persistence of the node.

Parameters
[in]multi_nodalIf false, the snapshot and following commitment are not aware of the contents of the child nodes.

Definition at line 548 of file transaction.h.

References Transactional::Snapshot< XN >::m_packet.

template<class XN>
Transactional::Transaction< XN >::Transaction ( const Snapshot< XN > &  x,
bool  multi_nodal = true 
)
inlineexplicitnoexcept
Parameters
[in]xThe snapshot containing the old value of node.
[in]multi_nodalIf false, the snapshot and following commitment are not aware of the contents of the child nodes.

Definition at line 557 of file transaction.h.

Member Function Documentation

template<class XN>
bool Transactional::Transaction< XN >::commit ( )
inline
template<class XN>
Snapshot<XN> Transactional::Transaction< XN >::newTransactionUsingSnapshotFor ( Node< XN > &  supernode)
inline

Prepares for a next transaction after taking a snapshot for supernode.

Returns
a snapshot for supernode.

Definition at line 633 of file transaction.h.

References Transactional::Snapshot< XN >::m_packet, and Transactional::Transaction< XN >::operator++().

template<class XN>
template<class T >
T::Payload& Transactional::Transaction< XN >::operator[] ( const shared_ptr< T > &  node)
inline
Returns
Copy-constructed Payload instance for node, which will be included in the commitment.

Definition at line 574 of file transaction.h.

template<class XN>
template<class T >
T::Payload& Transactional::Transaction< XN >::operator[] ( T &  node)
inline
Returns
Copy-constructed Payload instance for node, which will be included in the commitment.

Definition at line 579 of file transaction.h.

References Transactional::Snapshot< XN >::m_packet.

template<class XN>
int Transactional::Transaction< XN >::unmark ( const shared_ptr< XListener > &  x)
inline

Cancels reserved events made toward x.

Returns
# of unmarked events.

Definition at line 604 of file transaction.h.


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

Generated for KAME4 by  doxygen 1.8.3