#include "FreeList.h"
#include "ithread.h"
#include "LinkedList.h"
#include "ThreadPool.h"
Go to the source code of this file.
|
#define | INVALID_EVENT_ID (-10 & 1<<29) |
|
◆ TimeoutType
◆ TimerEvent
Struct to contain information for a timer event.
Internal to the TimerThread.
◆ TimerThread
A timer thread similar to the one in the Upnp SDK that allows the scheduling of a job to run at a specified time in the future.
Because the timer thread uses the thread pool there is no gurantee of timing, only approximate timing.
Uses ThreadPool, Mutex, Condition, Thread.
◆ timeoutType
Timeout Types.
Enumerator |
---|
ABS_SEC | seconds from Jan 1, 1970.
|
REL_SEC | seconds from current time.
|
◆ TimerThreadInit()
Initializes and starts timer thread.
- Returns
- 0 on success, nonzero on failure. Returns error from ThreadPoolAddPersistent on failure.
- Parameters
-
[in] | timer | Valid timer thread pointer. |
[in] | tp | Valid thread pool to use. Must be started. Must be valid for lifetime of timer. Timer must be shutdown BEFORE thread pool. |
◆ TimerThreadRemove()
Removes an event from the timer Q.
Events can only be removed before they have been placed in the thread pool.
- Returns
- 0 on success, INVALID_EVENT_ID on failure.
- Parameters
-
[in] | timer | Valid timer thread pointer. |
[in] | id | Id of event to remove. |
[in] | out | Space for thread pool job. |
Referenced by free_client_subscription().
◆ TimerThreadSchedule()
Schedules an event to run at a specified time.
- Returns
- 0 on success, nonzero on failure, EOUTOFMEM if not enough memory to schedule job.
- Parameters
-
[in] | timer | Valid timer thread pointer. |
[in] | time | time of event. Either in absolute seconds, or relative seconds in the future. |
[in] | type | either ABS_SEC, or REL_SEC. If REL_SEC, then the event will be scheduled at the current time + REL_SEC. |
[in] | job | Valid Thread pool job with following fields. |
[in] | duration | . |
[in] | id | Id of timer event. (out, can be null). |
◆ TimerThreadShutdown()
Shutdown the timer thread.
Events scheduled in the future will NOT be run.
Timer thread should be shutdown BEFORE it's associated thread pool.
- Returns
- 0 if succesfull, nonzero otherwise. Always returns 0.
- Parameters
-
[in] | timer | Valid timer thread pointer. |