Windows XP, 2000 or higher version of Operating System support API called Windows Timer Queue. ProudNet also has a corresponding API that allows you to use that function much easily.
Timer Queue runs a function designated by user in scheduled time from one of threads in Thread pool. If every thread is busy operating something (running state) then the execution of function gets held until any thread becomes available.
When user function is called from Timer queue, one of threads in thread pool gets appointed to execute. But even though the execution of user function that was previously running hasn't been completed, a thread in idle state will be appointed to execute the function.
Let assum there is a task list as followed. The black arrow means 0.1 second and A,B,C,D,E are the tasks that need to be worked on at every 0.1 second. A,D get completed within 0.1 second, B gets completed right on 0.1 sec and C,E take more than 0.1 second.
If it is in Understanding server main loop method, then task list operates as shown in the diagram below. Since all tasks are being executed in a single thread, D and E can't start on time.
However, in Timer Queue method, there will be another thread appointed for operation of D and E will be executed from the thread completed the operation of C.
The biggest advantage of using Timer Queue is that it simply adds more threads for the need of executing tasks on schedule. In another words, more than two threads get appointed to operate user function simultaneously. Taking leverage on this feature, Timer Queue is being mainly used in server program.
Timer Queue enables parallelism but must bear a risk of having parallelism. Thus, please judge carefully whether or not parallelism of Timer Queue is needed in your project. (WARNING: If Timer Queue is misused, it could cause overload to threads of server process that may lead to slow down of performace! If you don't need to use Timer Queue then it is more effective to use Proud.CTimerThread or Managing Timer loop, RMI, Event from server.)
In order to use Timer queue, you need to access Proud.CTimerQueue class, which is singleton. Proud.CTimerQueueTimer objective will return when setting a function that is going to be called on a regular basis & calling cycle at Proud::NewTimerParam structure and inserting them into Proud.CTimerQueue.NewTimer’s parameter. And user function will be timely executed until Proud.CTimerQueueTimer object gets destroyed.