\href{http://travis-ci.org/franck34/qjobs}{\texttt{ }}\hypertarget{md_sfcode_node_modules_qjobs_Readme_autotoc_md23663}{}\doxysection{$<$strong$>$qjobs$<$/strong$>$}\label{md_sfcode_node_modules_qjobs_Readme_autotoc_md23663}
{\itshape {\bfseries{Efficient queue job manager module for nodejs.}}}\hypertarget{md_sfcode_node_modules_qjobs_Readme_autotoc_md23664}{}\doxysubsection{Features}\label{md_sfcode_node_modules_qjobs_Readme_autotoc_md23664}

\begin{DoxyItemize}
\item Concurrency limiter
\item Dynamic queue, a job can be added while the queue is running
\item Optional delay before continuing after max concurrency has been reached
\item Support of pause/unpause
\item Events emitter based\+: start, end, sleep, continu, job\+Start, job\+End
\item Quick statistic function, so you can know where the queue is, at regular interval
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_qjobs_Readme_autotoc_md23665}{}\doxysubsection{For what it can be usefull ?}\label{md_sfcode_node_modules_qjobs_Readme_autotoc_md23665}
Jobs which needs to run in parallels, but in a controled maner, example\+:
\begin{DoxyItemize}
\item Network scanners
\item Parallels monitoring jobs
\item Images/\+Videos related jobs
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_qjobs_Readme_autotoc_md23666}{}\doxysubsection{Compatibility \+:}\label{md_sfcode_node_modules_qjobs_Readme_autotoc_md23666}

\begin{DoxyItemize}
\item not tested with nodejs $<$ 0.\+10
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_qjobs_Readme_autotoc_md23667}{}\doxysubsection{Examples}\label{md_sfcode_node_modules_qjobs_Readme_autotoc_md23667}
(take a look at tests directory if you are looking for running samples)


\begin{DoxyCode}{0}
\DoxyCodeLine{var qjobs = new require('./qjobs');}
\DoxyCodeLine{                                }
\DoxyCodeLine{// My non blocking main job     }
\DoxyCodeLine{var myjob = function(args,next) \{}
\DoxyCodeLine{    setTimeout(function() \{}
\DoxyCodeLine{        console.log('Do something interesting here',args);}
\DoxyCodeLine{        next();}
\DoxyCodeLine{    \},1000);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{var q = new qjobs(\{maxConcurrency:10\});}
\DoxyCodeLine{}
\DoxyCodeLine{// Let's add 30 job to the queue}
\DoxyCodeLine{for (var i = 0; i<30; i++) \{}
\DoxyCodeLine{    q.add(myjob,[i,'test '+i]);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{q.on('start',function() \{}
\DoxyCodeLine{    console.log('Starting ...');}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{q.on('end',function() \{}
\DoxyCodeLine{    console.log('... All jobs done');}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{q.on('jobStart',function(args) \{}
\DoxyCodeLine{    console.log('jobStart',args);}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{q.on('jobEnd',function(args) \{}
\DoxyCodeLine{}
\DoxyCodeLine{    console.log('jobend',args);}
\DoxyCodeLine{}
\DoxyCodeLine{    // If i'm jobId 10, then make a pause of 5 sec}
\DoxyCodeLine{}
\DoxyCodeLine{    if (args.\_jobId == 10) \{}
\DoxyCodeLine{        q.pause(true);}
\DoxyCodeLine{        setTimeout(function() \{}
\DoxyCodeLine{            q.pause(false);}
\DoxyCodeLine{        \},5000);}
\DoxyCodeLine{    \}}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{q.on('pause',function(since) \{}
\DoxyCodeLine{    console.log('in pause since '+since+' milliseconds');}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{q.on('unpause',function() \{}
\DoxyCodeLine{    console.log('pause end, continu ..');}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{q.run();}
\DoxyCodeLine{}
\DoxyCodeLine{//q.abort() will empty jobs list}

\end{DoxyCode}
 