ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::Batch< S > Class Template Reference

a batch of RAII on the structure \( s \) [see batch()] More...

#include <ADS/Modification.h>

Public member functions

 Batch (S &s)
 opens a batch on \( s \)
 Batch (Batch &&b) noexcept
 the batch of \( b \), which no longer has it
 Batch (const Batch &)=delete
 not copied
Batch & operator= (const Batch &)=delete
 not assigned
Batch & operator= (Batch &&)=delete
 not assigned
 ~Batch () noexcept(false)
 closes the batch, if still open; if its scope exits by an exception, the structure goes back to the checkpoint when it is undoable and the events are dropped, else the observers get Rebuilt (or the events, if the structure has no Rebuilt)
void close (void)
 closes the batch: the outermost one sends the events, coalesced; idempotent
void rollback (void)
 brings the structure back to where it was when the batch opened, and drops its events: the observers see nothing

Detailed description

template<class S>
class ADS::Batch< S >

a batch of RAII on the structure \( s \) [see batch()]

Constructor and destructor documentation

◆ Batch() [1/3]

template<class S>
ADS::Batch< S >::Batch ( S & s)
inlineexplicit

opens a batch on \( s \)

◆ Batch() [2/3]

template<class S>
ADS::Batch< S >::Batch ( Batch< S > && b)
inlinenoexcept

the batch of \( b \), which no longer has it

◆ Batch() [3/3]

template<class S>
ADS::Batch< S >::Batch ( const Batch< S > & )
delete

not copied

◆ ~Batch()

template<class S>
ADS::Batch< S >::~Batch ( )
inline

closes the batch, if still open; if its scope exits by an exception, the structure goes back to the checkpoint when it is undoable and the events are dropped, else the observers get Rebuilt (or the events, if the structure has no Rebuilt)

Member function documentation

◆ close()

template<class S>
void ADS::Batch< S >::close ( void )
inline

closes the batch: the outermost one sends the events, coalesced; idempotent

In pseudocode (beyond the book), with \( d \) the depth of the batches, \( B \) the events collected and \( M_o \) the kinds that the observer \( o \) wants:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{procedure}\ \mathrm{close}() \cr 2 & \quad d \gets d - 1;\ \textbf{if}\ d > 0\ \textbf{then} \ \textbf{return} \cr 3 & \quad C \gets \mathrm{coalesce}( B );\ B \gets \emptyset \cr 4 & \quad \textbf{foreach}\ \text{observer } o\ \textbf{do} \cr 5 & \qquad C_o \gets \text{the events of } C \text{ whose kind is in } M_o \cr 6 & \qquad \textbf{if}\ C_o = \emptyset\ \textbf{then} \ \textbf{continue} \cr 7 & \qquad o.\mathrm{group\_begin}() \cr 8 & \qquad \textbf{if}\ o \text{ has a policy } p \textbf{ and } p.\mathrm{scratch}( o.\mathrm{reoptStats}( |C_o| ) ) \ \textbf{then}\ o.\mathrm{on}( \mathrm{Rebuilt} ) \cr 9 & \qquad \textbf{else}\ o.\mathrm{on}( C_o ) \cr 10 & \qquad o.\mathrm{group\_end}() \end{array}} \]

◆ operator=() [1/2]

template<class S>
Batch & ADS::Batch< S >::operator= ( Batch< S > && )
delete

not assigned

◆ operator=() [2/2]

template<class S>
Batch & ADS::Batch< S >::operator= ( const Batch< S > & )
delete

not assigned

◆ rollback()

template<class S>
void ADS::Batch< S >::rollback ( void )
inline

brings the structure back to where it was when the batch opened, and drops its events: the observers see nothing

Precondition
the structure can go back to the checkpoint (revertible(), when it has it)

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