\hypertarget{class_qore_1_1_thread_1_1_abstract_smart_lock}{}\section{Qore\+:\+:Thread\+:\+:Abstract\+Smart\+Lock Class Reference}
\label{class_qore_1_1_thread_1_1_abstract_smart_lock}\index{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}}


The abstract base class for locks that support the internal A\+PI for use with the \mbox{\hyperlink{class_qore_1_1_thread_1_1_condition}{Condition}} class.  




Inheritance diagram for Qore\+:\+:Thread\+:\+:Abstract\+Smart\+Lock\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=326pt]{class_qore_1_1_thread_1_1_abstract_smart_lock__inherit__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{class_qore_1_1_thread_1_1_abstract_smart_lock_af15ccf8b346a9f3abbbdc559d2f5e59b}{constructor}} ()
\begin{DoxyCompactList}\small\item\em Throws an exception if called directly; this class can only be instantiated by builtin subclasses. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} \mbox{\hyperlink{class_qore_1_1_thread_1_1_abstract_smart_lock_aaf6a2ecab96ad01d3ab0dbb81b63a363}{get\+Name}} ()
\begin{DoxyCompactList}\small\item\em Returns the name of the threading class directly inheriting this class. \end{DoxyCompactList}\item 
bool \mbox{\hyperlink{class_qore_1_1_thread_1_1_abstract_smart_lock_a4936d08a0508d61a41e8c685e2a03d72}{lock\+Owner}} ()
\begin{DoxyCompactList}\small\item\em Returns \mbox{\hyperlink{group__boolean__constants_ga3ba2df91713a6249449347131ea526c3}{True}} if the calling thread owns the lock, \mbox{\hyperlink{group__boolean__constants_ga9da2b9a8003cd3788e48305f8a00540f}{False}} if not. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} \mbox{\hyperlink{class_qore_1_1_thread_1_1_abstract_smart_lock_afafe6ef19203993a7c5dd87e00068325}{lock\+T\+ID}} ()
\begin{DoxyCompactList}\small\item\em Returns the T\+ID of the thread owning the lock or -\/1 if the lock is currently not acquired. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
The abstract base class for locks that support the internal A\+PI for use with the \mbox{\hyperlink{class_qore_1_1_thread_1_1_condition}{Condition}} class. 

\begin{DoxyParagraph}{Restrictions\+:}
\mbox{\hyperlink{group__parse__options_gade963e1fbbd1f5b2c777df7221512a1b}{Qore\+::\+P\+O\+\_\+\+N\+O\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+C\+L\+A\+S\+S\+ES}}
\end{DoxyParagraph}
This is an abstract class to be inherited by builtin classes that implement the internal Qore A\+PI that allows them to be used by the \mbox{\hyperlink{class_qore_1_1_thread_1_1_condition}{Condition}} class. Currently the \mbox{\hyperlink{class_qore_1_1_thread_1_1_r_w_lock}{R\+W\+Lock}} and \mbox{\hyperlink{class_qore_1_1_thread_1_1_mutex}{Mutex}} classes inherit this class.

This class cannot be instantiated directly and also cannot be directly inherited by user-\/defined classes.

\begin{DoxyNote}{Note}
This class is not available with the \mbox{\hyperlink{group__parse__options_gade963e1fbbd1f5b2c777df7221512a1b}{P\+O\+\_\+\+N\+O\+\_\+\+T\+H\+R\+E\+A\+D\+\_\+\+C\+L\+A\+S\+S\+ES}} parse option. 
\end{DoxyNote}


\subsection{Member Function Documentation}
\mbox{\Hypertarget{class_qore_1_1_thread_1_1_abstract_smart_lock_af15ccf8b346a9f3abbbdc559d2f5e59b}\label{class_qore_1_1_thread_1_1_abstract_smart_lock_af15ccf8b346a9f3abbbdc559d2f5e59b}} 
\index{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}!constructor@{constructor}}
\index{constructor@{constructor}!Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}}
\subsubsection{\texorpdfstring{constructor()}{constructor()}}
{\footnotesize\ttfamily Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock\+::constructor (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Throws an exception if called directly; this class can only be instantiated by builtin subclasses. 


\begin{DoxyExceptions}{Exceptions}
{\em A\+B\+S\+T\+R\+A\+C\+T\+S\+M\+A\+R\+T\+L\+O\+C\+K-\/\+C\+O\+N\+S\+T\+R\+U\+C\+T\+O\+R-\/\+E\+R\+R\+OR} & this exception is thrown if this class is constructed directly (also if directly inherited by user classes) \\
\hline
\end{DoxyExceptions}
\mbox{\Hypertarget{class_qore_1_1_thread_1_1_abstract_smart_lock_aaf6a2ecab96ad01d3ab0dbb81b63a363}\label{class_qore_1_1_thread_1_1_abstract_smart_lock_aaf6a2ecab96ad01d3ab0dbb81b63a363}} 
\index{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}!get\+Name@{get\+Name}}
\index{get\+Name@{get\+Name}!Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}}
\subsubsection{\texorpdfstring{get\+Name()}{getName()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock\+::get\+Name (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns the name of the threading class directly inheriting this class. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_CONSTANT}{C\+O\+N\+S\+T\+A\+NT}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
string name = lock.getName();
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
the name of the threading class directly inheriting this class 
\end{DoxyReturn}
\mbox{\Hypertarget{class_qore_1_1_thread_1_1_abstract_smart_lock_a4936d08a0508d61a41e8c685e2a03d72}\label{class_qore_1_1_thread_1_1_abstract_smart_lock_a4936d08a0508d61a41e8c685e2a03d72}} 
\index{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}!lock\+Owner@{lock\+Owner}}
\index{lock\+Owner@{lock\+Owner}!Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}}
\subsubsection{\texorpdfstring{lock\+Owner()}{lockOwner()}}
{\footnotesize\ttfamily bool Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock\+::lock\+Owner (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns \mbox{\hyperlink{group__boolean__constants_ga3ba2df91713a6249449347131ea526c3}{True}} if the calling thread owns the lock, \mbox{\hyperlink{group__boolean__constants_ga9da2b9a8003cd3788e48305f8a00540f}{False}} if not. 

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_CONSTANT}{C\+O\+N\+S\+T\+A\+NT}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
\textcolor{comment}{# only grab and release lock if we don't already own it}
bool lck = !lock.lockOwner();
\textcolor{keywordflow}{if} (lck)
    lock.lock();
on\_exit
    \textcolor{keywordflow}{if} (lck)
        lock.unlock();
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
\mbox{\hyperlink{group__boolean__constants_ga3ba2df91713a6249449347131ea526c3}{True}} if the calling thread owns the lock, \mbox{\hyperlink{group__boolean__constants_ga9da2b9a8003cd3788e48305f8a00540f}{False}} if not 
\end{DoxyReturn}
\mbox{\Hypertarget{class_qore_1_1_thread_1_1_abstract_smart_lock_afafe6ef19203993a7c5dd87e00068325}\label{class_qore_1_1_thread_1_1_abstract_smart_lock_afafe6ef19203993a7c5dd87e00068325}} 
\index{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}!lock\+T\+ID@{lock\+T\+ID}}
\index{lock\+T\+ID@{lock\+T\+ID}!Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock@{Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock}}
\subsubsection{\texorpdfstring{lock\+T\+I\+D()}{lockTID()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga2de8717e92c5f97ccc6511f6062d6502}{int}} Qore\+::\+Thread\+::\+Abstract\+Smart\+Lock\+::lock\+T\+ID (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Returns the T\+ID of the thread owning the lock or -\/1 if the lock is currently not acquired. 

This method normally not useful in practice for anything except checking that the current thread owns the lock, in which case \mbox{\hyperlink{class_qore_1_1_thread_1_1_abstract_smart_lock_a4936d08a0508d61a41e8c685e2a03d72}{Abstract\+Smart\+Lock\+::lock\+Owner()}} is better, because if the lock is not owned by the current thread the lock ownership can change at any time.

\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_CONSTANT}{C\+O\+N\+S\+T\+A\+NT}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}
int tid = lock.lockTID();
\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyReturn}{Returns}
the T\+ID of the thread owning the lock or -\/1 if the lock is currently not acquired 
\end{DoxyReturn}
