\hypertarget{classTransactionManager}{
\section{TransactionManager Class Reference}
\label{classTransactionManager}\index{TransactionManager@{TransactionManager}}
}


A class for managing transactions.  




{\ttfamily \#include $<$transaction.hh$>$}

Inheritance diagram for TransactionManager:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=1.944444cm]{classTransactionManager}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \hyperlink{classTransactionManager_1_1Transaction}{Transaction}
\begin{DoxyCompactList}\small\item\em \hyperlink{classTransactionManager_1_1Transaction}{Transaction} class, just a list of operations to be dispatched. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classTransactionManager_a2c830d5bba0f40ac5482cafb61031d3e}{
typedef \hyperlink{classref__ptr}{ref\_\-ptr}$<$ \hyperlink{classTransactionOperation}{TransactionOperation} $>$ {\bfseries Operation}}
\label{classTransactionManager_a2c830d5bba0f40ac5482cafb61031d3e}

\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classTransactionManager_ade292db613e191e7b9c242b9d5e9a4e8}{TransactionManager} (\hyperlink{classEventLoop}{EventLoop} \&e, uint32\_\-t timeout\_\-ms=0, uint32\_\-t max\_\-pending=10)
\begin{DoxyCompactList}\small\item\em Constuctor with a given event loop, timeout, and max pending commits. \item\end{DoxyCompactList}\item 
\hypertarget{classTransactionManager_ad322e5fcccc9ea0689f4a00c45632251}{
virtual \hyperlink{classTransactionManager_ad322e5fcccc9ea0689f4a00c45632251}{$\sim$TransactionManager} ()}
\label{classTransactionManager_ad322e5fcccc9ea0689f4a00c45632251}

\begin{DoxyCompactList}\small\item\em Destructor. \item\end{DoxyCompactList}\item 
bool \hyperlink{classTransactionManager_a08a2cefdbe3b8030a6b1d5d3f05d0840}{start} (uint32\_\-t \&new\_\-tid)
\begin{DoxyCompactList}\small\item\em Start transaction. \item\end{DoxyCompactList}\item 
bool \hyperlink{classTransactionManager_a5d55462616f35b4d2a64d7668f2358c9}{commit} (uint32\_\-t tid)
\begin{DoxyCompactList}\small\item\em Commit transaction. \item\end{DoxyCompactList}\item 
bool \hyperlink{classTransactionManager_a0aabead86eae7774671e4c9f8f63f8db}{abort} (uint32\_\-t tid)
\begin{DoxyCompactList}\small\item\em Abort transaction. \item\end{DoxyCompactList}\item 
virtual bool \hyperlink{classTransactionManager_aaf11352dee59a7f1fb63d29c040034f4}{add} (uint32\_\-t tid, const \hyperlink{classref__ptr}{Operation} \&op)
\begin{DoxyCompactList}\small\item\em Add operation to transaction. \item\end{DoxyCompactList}\item 
bool \hyperlink{classTransactionManager_aea80c71c078d92dd87a0962a6da68f6b}{retrieve\_\-size} (uint32\_\-t tid, uint32\_\-t \&count) const 
\begin{DoxyCompactList}\small\item\em Retrieve number of operations in pending transaction. \item\end{DoxyCompactList}\item 
uint32\_\-t \hyperlink{classTransactionManager_a4148acfeed709c35e82f2136b3b10236}{timeout\_\-ms} () const 
\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} inter-\/operation additional timeout. \item\end{DoxyCompactList}\item 
uint32\_\-t \hyperlink{classTransactionManager_a18421d431f8ce02ae30374350e8dd027}{max\_\-pending} () const 
\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} maximum number of uncommited pending transactions. \item\end{DoxyCompactList}\item 
uint32\_\-t \hyperlink{classTransactionManager_ab7e411e8ed6db4798e2003ee1d0be1db}{pending} () const 
\begin{DoxyCompactList}\small\item\em Get \hyperlink{protocolthe-p}{the} current number of uncommited pending transactions. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
virtual void \hyperlink{classTransactionManager_ad7f9e60f752550fffc693cbba51b097e}{pre\_\-commit} (uint32\_\-t tid)
\begin{DoxyCompactList}\small\item\em Overrideable function that can be called before \hyperlink{protocolthe-p}{the} first operation in a commit is dispatched. \item\end{DoxyCompactList}\item 
virtual void \hyperlink{classTransactionManager_a39f7981f4211fa1bdcb568b7a37cf319}{post\_\-commit} (uint32\_\-t tid)
\begin{DoxyCompactList}\small\item\em Overrideable function that can be called after commit occurs. \item\end{DoxyCompactList}\item 
virtual void \hyperlink{classTransactionManager_aedae741412cf8c92f0da9b46e378dc34}{operation\_\-result} (bool success, const \hyperlink{classTransactionOperation}{TransactionOperation} \&op)
\begin{DoxyCompactList}\small\item\em Overrideable function that is called immediately after an individual operation is dispatched. \item\end{DoxyCompactList}\item 
bool \hyperlink{classTransactionManager_ad9f39116c6dc10902625d5655c9b018c}{flush} (uint32\_\-t tid)
\begin{DoxyCompactList}\small\item\em Flush operations in transaction list. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Types}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classTransactionManager_a595993c353fc29d0c4710222295d08b4}{
typedef map$<$ uint32\_\-t, \hyperlink{classTransactionManager_1_1Transaction}{Transaction} $>$ {\bfseries TransactionDB}}
\label{classTransactionManager_a595993c353fc29d0c4710222295d08b4}

\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classTransactionManager_a7da71294d5718bb9f40a7f99533cdaa0}{
void \hyperlink{classTransactionManager_a7da71294d5718bb9f40a7f99533cdaa0}{timeout} (uint32\_\-t tid)}
\label{classTransactionManager_a7da71294d5718bb9f40a7f99533cdaa0}

\begin{DoxyCompactList}\small\item\em Called when timeout timer expires. \item\end{DoxyCompactList}\item 
void \hyperlink{classTransactionManager_a75529ef3788c2e50e06340de2ce76ed6}{crank\_\-tid} ()
\begin{DoxyCompactList}\small\item\em Increment next transaction id by a randomized amount. \item\end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classTransactionManager_a897690618b1577e7492aa65c1fb4cb16}{
\hyperlink{classEventLoop}{EventLoop} \& {\bfseries \_\-e}}
\label{classTransactionManager_a897690618b1577e7492aa65c1fb4cb16}

\item 
\hypertarget{classTransactionManager_aa90f132fc22fe5fe3eb486f0c57c8aa4}{
TransactionDB {\bfseries \_\-transactions}}
\label{classTransactionManager_aa90f132fc22fe5fe3eb486f0c57c8aa4}

\item 
\hypertarget{classTransactionManager_a2209c4ee3795428d311125557865ff9e}{
uint32\_\-t {\bfseries \_\-timeout\_\-ms}}
\label{classTransactionManager_a2209c4ee3795428d311125557865ff9e}

\item 
\hypertarget{classTransactionManager_a0ca88490ab106965aab95b862d29464d}{
uint32\_\-t {\bfseries \_\-max\_\-pending}}
\label{classTransactionManager_a0ca88490ab106965aab95b862d29464d}

\item 
\hypertarget{classTransactionManager_a2b4fe7fb53be0fd03fd63a204a8d4fd0}{
uint32\_\-t {\bfseries \_\-next\_\-tid}}
\label{classTransactionManager_a2b4fe7fb53be0fd03fd63a204a8d4fd0}

\end{DoxyCompactItemize}
\subsection*{Friends}
\begin{DoxyCompactItemize}
\item 
\hypertarget{classTransactionManager_a49982aa325e19f0956d42fde9132caa2}{
class {\bfseries Transaction}}
\label{classTransactionManager_a49982aa325e19f0956d42fde9132caa2}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
A class for managing transactions. The \hyperlink{classTransactionManager}{TransactionManager} creates, manages, and dispatches transactions. A \hyperlink{classTransactionManager_1_1Transaction}{Transaction} is comprised of a sequence of \hyperlink{classTransactionOperation}{TransactionOperation} s. Each transaction is uniquely identified by a transaction id. 

\subsection{Constructor \& Destructor Documentation}
\hypertarget{classTransactionManager_ade292db613e191e7b9c242b9d5e9a4e8}{
\index{TransactionManager@{TransactionManager}!TransactionManager@{TransactionManager}}
\index{TransactionManager@{TransactionManager}!TransactionManager@{TransactionManager}}
\subsubsection[{TransactionManager}]{\setlength{\rightskip}{0pt plus 5cm}TransactionManager::TransactionManager (
\begin{DoxyParamCaption}
\item[{{\bf EventLoop} \&}]{e, }
\item[{uint32\_\-t}]{timeout\_\-ms = {\ttfamily 0}, }
\item[{uint32\_\-t}]{max\_\-pending = {\ttfamily 10}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTransactionManager_ade292db613e191e7b9c242b9d5e9a4e8}


Constuctor with a given event loop, timeout, and max pending commits. 


\begin{DoxyParams}{Parameters}
{\em e} & \hyperlink{protocolthe-p}{the} \hyperlink{classEventLoop}{EventLoop} instance.\\
\hline
{\em timeout\_\-ms} & \hyperlink{protocolthe-p}{the} inter-\/operation addition timeout. If zero, timeouts are not used, otherwise a timeout will occur and \hyperlink{protocolthe-p}{the} transaction aborted if \hyperlink{protocolthe-p}{the} transaction is not updated for timeout\_\-ms.\\
\hline
{\em max\_\-pending} & \hyperlink{protocolthe-p}{the} maximum number of uncommitted transactions pending commit. \\
\hline
\end{DoxyParams}


\subsection{Member Function Documentation}
\hypertarget{classTransactionManager_a0aabead86eae7774671e4c9f8f63f8db}{
\index{TransactionManager@{TransactionManager}!abort@{abort}}
\index{abort@{abort}!TransactionManager@{TransactionManager}}
\subsubsection[{abort}]{\setlength{\rightskip}{0pt plus 5cm}bool TransactionManager::abort (
\begin{DoxyParamCaption}
\item[{uint32\_\-t}]{tid}
\end{DoxyParamCaption}
)}}
\label{classTransactionManager_a0aabead86eae7774671e4c9f8f63f8db}


Abort transaction. 


\begin{DoxyParams}{Parameters}
{\em tid} & \hyperlink{protocolthe-p}{the} transaction ID. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false on error. 
\end{DoxyReturn}
\hypertarget{classTransactionManager_aaf11352dee59a7f1fb63d29c040034f4}{
\index{TransactionManager@{TransactionManager}!add@{add}}
\index{add@{add}!TransactionManager@{TransactionManager}}
\subsubsection[{add}]{\setlength{\rightskip}{0pt plus 5cm}bool TransactionManager::add (
\begin{DoxyParamCaption}
\item[{uint32\_\-t}]{tid, }
\item[{const {\bf Operation} \&}]{op}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}virtual\mbox{]}}}}
\label{classTransactionManager_aaf11352dee59a7f1fb63d29c040034f4}


Add operation to transaction. 


\begin{DoxyParams}{Parameters}
{\em tid} & \hyperlink{protocolthe-p}{the} transaction ID. \\
\hline
{\em operation} & to be added. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false if tid is invalid. 
\end{DoxyReturn}
\hypertarget{classTransactionManager_a5d55462616f35b4d2a64d7668f2358c9}{
\index{TransactionManager@{TransactionManager}!commit@{commit}}
\index{commit@{commit}!TransactionManager@{TransactionManager}}
\subsubsection[{commit}]{\setlength{\rightskip}{0pt plus 5cm}bool TransactionManager::commit (
\begin{DoxyParamCaption}
\item[{uint32\_\-t}]{tid}
\end{DoxyParamCaption}
)}}
\label{classTransactionManager_a5d55462616f35b4d2a64d7668f2358c9}


Commit transaction. 


\begin{DoxyParams}{Parameters}
{\em tid} & \hyperlink{protocolthe-p}{the} transaction ID. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false on error. 
\end{DoxyReturn}
\hypertarget{classTransactionManager_a75529ef3788c2e50e06340de2ce76ed6}{
\index{TransactionManager@{TransactionManager}!crank\_\-tid@{crank\_\-tid}}
\index{crank\_\-tid@{crank\_\-tid}!TransactionManager@{TransactionManager}}
\subsubsection[{crank\_\-tid}]{\setlength{\rightskip}{0pt plus 5cm}void TransactionManager::crank\_\-tid (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}
\label{classTransactionManager_a75529ef3788c2e50e06340de2ce76ed6}


Increment next transaction id by a randomized amount. 

\hypertarget{classTransactionManager_ad9f39116c6dc10902625d5655c9b018c}{
\index{TransactionManager@{TransactionManager}!flush@{flush}}
\index{flush@{flush}!TransactionManager@{TransactionManager}}
\subsubsection[{flush}]{\setlength{\rightskip}{0pt plus 5cm}bool TransactionManager::flush (
\begin{DoxyParamCaption}
\item[{uint32\_\-t}]{tid}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}protected\mbox{]}}}}
\label{classTransactionManager_ad9f39116c6dc10902625d5655c9b018c}


Flush operations in transaction list. 

May be use by \hyperlink{classTransactionManager_aedae741412cf8c92f0da9b46e378dc34}{operation\_\-result} methods to safely prevent further operations being dispatched when errors are detected. \hyperlink{classTransactionManager_ad9f39116c6dc10902625d5655c9b018c}{flush()} always succeeds if transaction exists.


\begin{DoxyParams}{Parameters}
{\em tid} & transaction id of transaction to be flushed.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if transaction exists, false otherwise. 
\end{DoxyReturn}
\hypertarget{classTransactionManager_a18421d431f8ce02ae30374350e8dd027}{
\index{TransactionManager@{TransactionManager}!max\_\-pending@{max\_\-pending}}
\index{max\_\-pending@{max\_\-pending}!TransactionManager@{TransactionManager}}
\subsubsection[{max\_\-pending}]{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t TransactionManager::max\_\-pending (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTransactionManager_a18421d431f8ce02ae30374350e8dd027}


Get \hyperlink{protocolthe-p}{the} maximum number of uncommited pending transactions. 

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} maximum number of uncommitted transactions pending commit. 
\end{DoxyReturn}
\hypertarget{classTransactionManager_aedae741412cf8c92f0da9b46e378dc34}{
\index{TransactionManager@{TransactionManager}!operation\_\-result@{operation\_\-result}}
\index{operation\_\-result@{operation\_\-result}!TransactionManager@{TransactionManager}}
\subsubsection[{operation\_\-result}]{\setlength{\rightskip}{0pt plus 5cm}void TransactionManager::operation\_\-result (
\begin{DoxyParamCaption}
\item[{bool}]{success, }
\item[{const {\bf TransactionOperation} \&}]{op}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}protected, virtual\mbox{]}}}}
\label{classTransactionManager_aedae741412cf8c92f0da9b46e378dc34}


Overrideable function that is called immediately after an individual operation is dispatched. 

Default implementation is a no-\/op.


\begin{DoxyParams}{Parameters}
{\em success} & whether \hyperlink{protocolthe-p}{the} operation succeed.\\
\hline
{\em op} & \hyperlink{protocolthe-p}{the} operation. \\
\hline
\end{DoxyParams}


Reimplemented in \hyperlink{classFibConfigTransactionManager_a3908609245b4ea633c00e9364a0ef422}{FibConfigTransactionManager}, \hyperlink{classFirewallTransactionManager_a481d4b3ac74f14cd268274dc7e7b5159}{FirewallTransactionManager}, and \hyperlink{classIfConfigTransactionManager_a7bfbb7fb02f9b55a232cbdd16ea9fe4c}{IfConfigTransactionManager}.

\hypertarget{classTransactionManager_ab7e411e8ed6db4798e2003ee1d0be1db}{
\index{TransactionManager@{TransactionManager}!pending@{pending}}
\index{pending@{pending}!TransactionManager@{TransactionManager}}
\subsubsection[{pending}]{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t TransactionManager::pending (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTransactionManager_ab7e411e8ed6db4798e2003ee1d0be1db}


Get \hyperlink{protocolthe-p}{the} current number of uncommited pending transactions. 

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} current number of uncommitted transactions pending commit. 
\end{DoxyReturn}
\hypertarget{classTransactionManager_a39f7981f4211fa1bdcb568b7a37cf319}{
\index{TransactionManager@{TransactionManager}!post\_\-commit@{post\_\-commit}}
\index{post\_\-commit@{post\_\-commit}!TransactionManager@{TransactionManager}}
\subsubsection[{post\_\-commit}]{\setlength{\rightskip}{0pt plus 5cm}void TransactionManager::post\_\-commit (
\begin{DoxyParamCaption}
\item[{uint32\_\-t}]{tid}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}protected, virtual\mbox{]}}}}
\label{classTransactionManager_a39f7981f4211fa1bdcb568b7a37cf319}


Overrideable function that can be called after commit occurs. 

Default implementation is a no-\/op. 

Reimplemented in \hyperlink{classFibConfigTransactionManager_a211c1e586a6a809af996efd9647ad98d}{FibConfigTransactionManager}.

\hypertarget{classTransactionManager_ad7f9e60f752550fffc693cbba51b097e}{
\index{TransactionManager@{TransactionManager}!pre\_\-commit@{pre\_\-commit}}
\index{pre\_\-commit@{pre\_\-commit}!TransactionManager@{TransactionManager}}
\subsubsection[{pre\_\-commit}]{\setlength{\rightskip}{0pt plus 5cm}void TransactionManager::pre\_\-commit (
\begin{DoxyParamCaption}
\item[{uint32\_\-t}]{tid}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}protected, virtual\mbox{]}}}}
\label{classTransactionManager_ad7f9e60f752550fffc693cbba51b097e}


Overrideable function that can be called before \hyperlink{protocolthe-p}{the} first operation in a commit is dispatched. 

Default implementation is a no-\/op. 

Reimplemented in \hyperlink{classFibConfigTransactionManager_a424dd7689a179695b9ec0912d8d68171}{FibConfigTransactionManager}, \hyperlink{classFirewallTransactionManager_aa500bbec2eb89d812e0b468e76059696}{FirewallTransactionManager}, and \hyperlink{classIfConfigTransactionManager_a921d6d843c9476b7129662741d3cc2a3}{IfConfigTransactionManager}.

\hypertarget{classTransactionManager_aea80c71c078d92dd87a0962a6da68f6b}{
\index{TransactionManager@{TransactionManager}!retrieve\_\-size@{retrieve\_\-size}}
\index{retrieve\_\-size@{retrieve\_\-size}!TransactionManager@{TransactionManager}}
\subsubsection[{retrieve\_\-size}]{\setlength{\rightskip}{0pt plus 5cm}bool TransactionManager::retrieve\_\-size (
\begin{DoxyParamCaption}
\item[{uint32\_\-t}]{tid, }
\item[{uint32\_\-t \&}]{count}
\end{DoxyParamCaption}
) const}}
\label{classTransactionManager_aea80c71c078d92dd87a0962a6da68f6b}


Retrieve number of operations in pending transaction. 


\begin{DoxyParams}{Parameters}
{\em tid} & \hyperlink{protocolthe-p}{the} transaction ID.\\
\hline
{\em count} & variable to be assigned number of operations in transaction.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if tid is valid, false otherwise. 
\end{DoxyReturn}
\hypertarget{classTransactionManager_a08a2cefdbe3b8030a6b1d5d3f05d0840}{
\index{TransactionManager@{TransactionManager}!start@{start}}
\index{start@{start}!TransactionManager@{TransactionManager}}
\subsubsection[{start}]{\setlength{\rightskip}{0pt plus 5cm}bool TransactionManager::start (
\begin{DoxyParamCaption}
\item[{uint32\_\-t \&}]{new\_\-tid}
\end{DoxyParamCaption}
)}}
\label{classTransactionManager_a08a2cefdbe3b8030a6b1d5d3f05d0840}


Start transaction. 


\begin{DoxyParams}{Parameters}
{\em new\_\-tid} & variable to assigned new transaction id.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true on success, false if maximum number of pending transactions is reached. 
\end{DoxyReturn}
\hypertarget{classTransactionManager_a4148acfeed709c35e82f2136b3b10236}{
\index{TransactionManager@{TransactionManager}!timeout\_\-ms@{timeout\_\-ms}}
\index{timeout\_\-ms@{timeout\_\-ms}!TransactionManager@{TransactionManager}}
\subsubsection[{timeout\_\-ms}]{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t TransactionManager::timeout\_\-ms (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{classTransactionManager_a4148acfeed709c35e82f2136b3b10236}


Get \hyperlink{protocolthe-p}{the} inter-\/operation additional timeout. 

If \hyperlink{protocolthe-p}{the} inter-\/operation addition timeout is zero, timeouts are not used, otherwise a timeout will occur and \hyperlink{protocolthe-p}{the} transaction aborted if \hyperlink{protocolthe-p}{the} transaction is not updated for timeout\_\-ms.

\begin{DoxyReturn}{Returns}
\hyperlink{protocolthe-p}{the} inter-\/operation additional timeout. 
\end{DoxyReturn}


The documentation for this class was generated from the following files:\begin{DoxyCompactItemize}
\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/transaction.hh\item 
/home/greearb/git/xorp.ct.github/xorp/libxorp/transaction.cc\end{DoxyCompactItemize}
