\hypertarget{a00920}{\section{Open\+Flipper\+Thread Class Reference}
\label{a00920}\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
}


Thread handling class for Open\+Flipper.  




{\ttfamily \#include $<$Open\+Flipper/threads/\+Open\+Flipper\+Thread.\+hh$>$}

Inheritance diagram for Open\+Flipper\+Thread\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3.000000cm]{a00920}
\end{center}
\end{figure}
\subsection*{Signals}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{a00920_ac0e215454748b3859ce193fa3271a463}{start\+Processing\+Internal} ()
\begin{DoxyCompactList}\small\item\em start processing of a function \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{a00920_a2f61c2c3cac596dad51f68ae6f3d0e91}{{\bfseries Open\+Flipper\+Thread} (Q\+String \+\_\+job\+Id)}\label{a00920_a2f61c2c3cac596dad51f68ae6f3d0e91}

\end{DoxyCompactItemize}
\subsection*{Private Slots}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{a00920_a7df8a9a48107b7c6c92927297e2cac02}{slot\+Job\+Finished} ()
\begin{DoxyCompactList}\small\item\em job has finished \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hyperlink{a00918}{Open\+Flipper\+Job} $\ast$ \hyperlink{a00920_a3d703023400cf4b2ceb1fdd04a2002b8}{job\+\_\+}
\begin{DoxyCompactList}\small\item\em Internal job wrapper. \end{DoxyCompactList}\item 
Q\+String \hyperlink{a00920_aa8dcc8edd5d329c1c18069a5c528f825}{job\+Id\+\_\+}
\begin{DoxyCompactList}\small\item\em Id of the current job. \end{DoxyCompactList}\item 
Q\+Semaphore \hyperlink{a00920_a0064b4613b7adcc2b6817a300ddcd173}{startup\+\_\+}
\begin{DoxyCompactList}\small\item\em Semaphore to control order of thread startup calls. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Advanced job processing}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{a00920_a6878d366fb0ec02eaf25db1163cfa5b8}{run} ()
\begin{DoxyCompactList}\small\item\em Main processing. \end{DoxyCompactList}\item 
virtual void \hyperlink{a00920_a52b846d7205201c48d21267228b54de5}{cancel} ()
\begin{DoxyCompactList}\small\item\em Cancel the job. \end{DoxyCompactList}\item 
\hypertarget{a00920_a1d353488786a7984dadb55f71db1f844}{Q\+String \hyperlink{a00920_a1d353488786a7984dadb55f71db1f844}{job\+Id} ()}\label{a00920_a1d353488786a7984dadb55f71db1f844}

\begin{DoxyCompactList}\small\item\em get Job\+Id get the Id of the current Job \end{DoxyCompactList}\item 
void \hyperlink{a00920_abe9badd14a386d6e61e060ad6d65d8f3}{slot\+Cancel} (Q\+String \+\_\+job\+Id)
\begin{DoxyCompactList}\small\item\em Cancel this job. \end{DoxyCompactList}\item 
void \hyperlink{a00920_aab4287c49391f9b54554f646538f4f8b}{state} (Q\+String \+\_\+job\+Id, int \+\_\+state)
\begin{DoxyCompactList}\small\item\em Tell core about job state. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Simple job processing}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{a00920_a007c870b15292d058ac2faf4975f14f5}{start\+Processing} ()
\begin{DoxyCompactList}\small\item\em start processing \end{DoxyCompactList}\item 
void \hyperlink{a00920_a6242c285f0b56225a64c94a4e70d4b9c}{function} (const Q\+String \+\_\+job\+Id=\char`\"{}\char`\"{})
\begin{DoxyCompactList}\small\item\em job function \end{DoxyCompactList}\item 
void \hyperlink{a00920_adba457119f0c198cef6f71db2665291c}{finished} (Q\+String \+\_\+job\+Id)
\begin{DoxyCompactList}\small\item\em job done \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Thread handling class for Open\+Flipper. 

Instantiate this class in order to provide a thread to a plugin. Unless you don't need a specialized \hyperlink{a00920_a6878d366fb0ec02eaf25db1163cfa5b8}{run()} or \hyperlink{a00920_a52b846d7205201c48d21267228b54de5}{cancel()} function, it won't be necessary to reimplement this class. Just connect the signals for the thread to work properly.

Note\+: Updating G\+U\+I elements of the main window from within a thread which is not the main thread can cause unexpected crashes to Open\+Flipper. This introduces some major limitations to the usage of threads in plugins. These include avoiding the creation of new objects and generally every function that produces logging messages.

The class should be used along with \hyperlink{processInterfacePage}{Process Interface}

It is not necessary to derive from this class for most operations, but you can. 

Definition at line 83 of file Open\+Flipper\+Thread.\+hh.



\subsection{Member Function Documentation}
\hypertarget{a00920_a52b846d7205201c48d21267228b54de5}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!cancel@{cancel}}
\index{cancel@{cancel}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{cancel}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::cancel (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{a00920_a52b846d7205201c48d21267228b54de5}


Cancel the job. 

Reimplement this function to correctly terminate your job. If your job is able to terminate correctly then you can reimplement this function and stop your process. 

Reimplemented in \hyperlink{a00485_ab3d8bf3e473210d1887c7af8d0c40c0a}{Decimate\+Thread}.



Definition at line 101 of file Open\+Flipper\+Thread.\+cc.

\hypertarget{a00920_adba457119f0c198cef6f71db2665291c}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!finished@{finished}}
\index{finished@{finished}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{finished}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::finished (
\begin{DoxyParamCaption}
\item[{Q\+String}]{\+\_\+job\+Id}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [signal]}}}\label{a00920_adba457119f0c198cef6f71db2665291c}


job done 

This signal is emitted if your job has finished and should be used to tell the core that your job has finished. \hypertarget{a00920_a6242c285f0b56225a64c94a4e70d4b9c}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!function@{function}}
\index{function@{function}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{function}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::function (
\begin{DoxyParamCaption}
\item[{const Q\+String}]{\+\_\+job\+Id = {\ttfamily \char`\"{}\char`\"{}}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [signal]}}}\label{a00920_a6242c285f0b56225a64c94a4e70d4b9c}


job function 

If you do not specialize the \hyperlink{a00920}{Open\+Flipper\+Thread}, The function connected to this signal will be used as the processing function for your thread. When you call 
\begin{DoxyCode}
OpenFlipper::startProcessing();
\end{DoxyCode}


You have connect one of your slot using 
\begin{DoxyCode}
connect( \hyperlink{a00920}{OpenFlipperThread} ,SIGNAL(\textcolor{keyword}{function}()),YourPlugin,SLOT(YourSlot(),
      Qt::DirectConnection) );
\end{DoxyCode}


The default implementation will call your slot inside the new thread and the core will still respond.

The optional parameter contains the job's id. In some cases the function that is to be called needs the job's id for further processing (status updates, etc.) \hypertarget{a00920_a6878d366fb0ec02eaf25db1163cfa5b8}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!run@{run}}
\index{run@{run}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{run}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::run (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{a00920_a6878d366fb0ec02eaf25db1163cfa5b8}


Main processing. 

Do not reimplement this function. Connect the \hyperlink{a00920_a6242c285f0b56225a64c94a4e70d4b9c}{function()} signal with your running function. Use signal \hyperlink{a00920_aab4287c49391f9b54554f646538f4f8b}{state()} in order to inform the core about the job's current state. 

Definition at line 68 of file Open\+Flipper\+Thread.\+cc.

\hypertarget{a00920_abe9badd14a386d6e61e060ad6d65d8f3}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!slot\+Cancel@{slot\+Cancel}}
\index{slot\+Cancel@{slot\+Cancel}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{slot\+Cancel}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::slot\+Cancel (
\begin{DoxyParamCaption}
\item[{Q\+String}]{\+\_\+job\+Id}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [slot]}}}\label{a00920_abe9badd14a386d6e61e060ad6d65d8f3}


Cancel this job. 

Call this slot with the correct job id to abort processing This directly calls \hyperlink{a00920_a52b846d7205201c48d21267228b54de5}{cancel()} This is only useful when you derived from this class, as other jobs might not react on this slot 

Definition at line 105 of file Open\+Flipper\+Thread.\+cc.

\hypertarget{a00920_a7df8a9a48107b7c6c92927297e2cac02}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!slot\+Job\+Finished@{slot\+Job\+Finished}}
\index{slot\+Job\+Finished@{slot\+Job\+Finished}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{slot\+Job\+Finished}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::slot\+Job\+Finished (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [private]}, {\ttfamily [slot]}}}\label{a00920_a7df8a9a48107b7c6c92927297e2cac02}


job has finished 

Called by the job wrapper, when the job is done. 

Definition at line 111 of file Open\+Flipper\+Thread.\+cc.

\hypertarget{a00920_a007c870b15292d058ac2faf4975f14f5}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!start\+Processing@{start\+Processing}}
\index{start\+Processing@{start\+Processing}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{start\+Processing}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::start\+Processing (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [slot]}}}\label{a00920_a007c870b15292d058ac2faf4975f14f5}


start processing 

This function will start the actual processing of a job. 

Definition at line 118 of file Open\+Flipper\+Thread.\+cc.

\hypertarget{a00920_ac0e215454748b3859ce193fa3271a463}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!start\+Processing\+Internal@{start\+Processing\+Internal}}
\index{start\+Processing\+Internal@{start\+Processing\+Internal}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{start\+Processing\+Internal}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::start\+Processing\+Internal (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [signal]}}}\label{a00920_ac0e215454748b3859ce193fa3271a463}


start processing of a function 

(I\+N\+T\+E\+R\+N\+A\+L!) ~\newline
This signal is used to start the process execution through the wrapper \hypertarget{a00920_aab4287c49391f9b54554f646538f4f8b}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!state@{state}}
\index{state@{state}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{state}]{\setlength{\rightskip}{0pt plus 5cm}void Open\+Flipper\+Thread\+::state (
\begin{DoxyParamCaption}
\item[{Q\+String}]{\+\_\+job\+Id, }
\item[{int}]{\+\_\+state}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [signal]}}}\label{a00920_aab4287c49391f9b54554f646538f4f8b}


Tell core about job state. 

Use this signal to inform core about the job's state if and only if the thread class inherits from \hyperlink{a00920}{Open\+Flipper\+Thread} and the virtual \hyperlink{a00920_a6878d366fb0ec02eaf25db1163cfa5b8}{run()} function is overridden. In all other cases this signal won't be used and does not have to be connected to from within the plugins. 

\subsection{Member Data Documentation}
\hypertarget{a00920_a3d703023400cf4b2ceb1fdd04a2002b8}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!job\+\_\+@{job\+\_\+}}
\index{job\+\_\+@{job\+\_\+}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{job\+\_\+}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Open\+Flipper\+Job}$\ast$ Open\+Flipper\+Thread\+::job\+\_\+\hspace{0.3cm}{\ttfamily [private]}}}\label{a00920_a3d703023400cf4b2ceb1fdd04a2002b8}


Internal job wrapper. 

(I\+N\+T\+E\+R\+N\+A\+L!) ~\newline
This wrapper is used to start slots inside the event queue of the current thread. All slots defined in the Q\+Thread object live in the callers thread(\+The main thread). All slots inside the wrapper live in the thread created by Q\+Thread. and therefore do not lock the main event loop 

Definition at line 211 of file Open\+Flipper\+Thread.\+hh.

\hypertarget{a00920_aa8dcc8edd5d329c1c18069a5c528f825}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!job\+Id\+\_\+@{job\+Id\+\_\+}}
\index{job\+Id\+\_\+@{job\+Id\+\_\+}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{job\+Id\+\_\+}]{\setlength{\rightskip}{0pt plus 5cm}Q\+String Open\+Flipper\+Thread\+::job\+Id\+\_\+\hspace{0.3cm}{\ttfamily [private]}}}\label{a00920_aa8dcc8edd5d329c1c18069a5c528f825}


Id of the current job. 

This holds the id of the current job. Most functions only react if the correct id is passed to the function. 

Definition at line 218 of file Open\+Flipper\+Thread.\+hh.

\hypertarget{a00920_a0064b4613b7adcc2b6817a300ddcd173}{\index{Open\+Flipper\+Thread@{Open\+Flipper\+Thread}!startup\+\_\+@{startup\+\_\+}}
\index{startup\+\_\+@{startup\+\_\+}!Open\+Flipper\+Thread@{Open\+Flipper\+Thread}}
\subsubsection[{startup\+\_\+}]{\setlength{\rightskip}{0pt plus 5cm}Q\+Semaphore Open\+Flipper\+Thread\+::startup\+\_\+\hspace{0.3cm}{\ttfamily [private]}}}\label{a00920_a0064b4613b7adcc2b6817a300ddcd173}


Semaphore to control order of thread startup calls. 

This variable is used to control the order of thread startup calls. The Thread itself is started, and when it is up and running, the resource will be created. The core thread waits for this resource and afterwards starts execution of the threads processing function. Without this sync, the processing call of the main thread might get lost as the thread is not online and listening for the signal. 

Definition at line 228 of file Open\+Flipper\+Thread.\+hh.



The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
Open\+Flipper/threads/Open\+Flipper\+Thread.\+hh\item 
Open\+Flipper/threads/Open\+Flipper\+Thread.\+cc\end{DoxyCompactItemize}
