Doxygen.
git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@432 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
parent
7f4bac9727
commit
5c008e3634
@ -29,14 +29,24 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef FREE_LIST_H
|
||||
#define FREE_LIST_H
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "ithread.h"
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -29,21 +29,32 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef LINKED_LIST_H
|
||||
#define LINKED_LIST_H
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "FreeList.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define EOUTOFMEM (-7 & 1<<29)
|
||||
|
||||
|
||||
#define FREELISTSIZE 100
|
||||
#define LIST_SUCCESS 1
|
||||
#define LIST_FAIL 0
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: free_routine
|
||||
*
|
||||
@ -52,6 +63,7 @@ extern "C" {
|
||||
*****************************************************************************/
|
||||
typedef void (*free_function)(void *arg);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmp_routine
|
||||
*
|
||||
@ -61,6 +73,7 @@ typedef void (*free_function)(void *arg);
|
||||
*****************************************************************************/
|
||||
typedef int (*cmp_routine)(void *itemA,void *itemB);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ListNode
|
||||
*
|
||||
@ -75,6 +88,7 @@ typedef struct LISTNODE
|
||||
void *item;
|
||||
} ListNode;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: LinkedList
|
||||
*
|
||||
@ -104,6 +118,7 @@ typedef struct LINKEDLIST
|
||||
cmp_routine cmp_func; /* compare function to use */
|
||||
} LinkedList;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListInit
|
||||
*
|
||||
@ -119,6 +134,7 @@ typedef struct LINKEDLIST
|
||||
*****************************************************************************/
|
||||
int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListAddHead
|
||||
*
|
||||
@ -135,6 +151,7 @@ int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
|
||||
*****************************************************************************/
|
||||
ListNode *ListAddHead(LinkedList *list, void *item);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListAddTail
|
||||
*
|
||||
@ -151,6 +168,7 @@ ListNode *ListAddHead(LinkedList *list, void *item);
|
||||
*****************************************************************************/
|
||||
ListNode *ListAddTail(LinkedList *list, void *item);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListAddAfter
|
||||
*
|
||||
@ -205,6 +223,7 @@ ListNode *ListAddBefore(LinkedList *list,void *item, ListNode *anode);
|
||||
*****************************************************************************/
|
||||
void *ListDelNode(LinkedList *list,ListNode *dnode, int freeItem);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListDestroy
|
||||
*
|
||||
@ -240,6 +259,7 @@ int ListDestroy(LinkedList *list, int freeItem);
|
||||
*****************************************************************************/
|
||||
ListNode* ListHead(LinkedList *list);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListTail
|
||||
*
|
||||
@ -256,6 +276,7 @@ ListNode* ListHead(LinkedList *list);
|
||||
*****************************************************************************/
|
||||
ListNode* ListTail(LinkedList *list);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListNext
|
||||
*
|
||||
@ -272,6 +293,7 @@ ListNode* ListTail(LinkedList *list);
|
||||
*****************************************************************************/
|
||||
ListNode* ListNext(LinkedList *list, ListNode * node);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListPrev
|
||||
*
|
||||
@ -288,6 +310,7 @@ ListNode* ListNext(LinkedList *list, ListNode * node);
|
||||
*****************************************************************************/
|
||||
ListNode* ListPrev(LinkedList *list, ListNode * node);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListFind
|
||||
*
|
||||
@ -307,6 +330,7 @@ ListNode* ListPrev(LinkedList *list, ListNode * node);
|
||||
*****************************************************************************/
|
||||
ListNode* ListFind(LinkedList *list, ListNode *start, void * item);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ListSize
|
||||
*
|
||||
|
@ -29,80 +29,129 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef THREADPOOL_H
|
||||
#define THREADPOOL_H
|
||||
|
||||
#ifdef UPNP_USE_MSVCPP
|
||||
#define UPNP_INLINE
|
||||
#else
|
||||
#define UPNP_INLINE inline
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "FreeList.h"
|
||||
#include "ithread.h"
|
||||
#include "LinkedList.h"
|
||||
#include "UpnpGlobal.h" /* for UPNP_INLINE, EXPORT_SPEC */
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include <time.h>
|
||||
#include <winsock2.h>
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest; /* minutes W of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||
#else /* WIN32 */
|
||||
#include <sys/time.h> /* for gettimeofday() */
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Size of job free list */
|
||||
|
||||
/*! Size of job free list */
|
||||
#define JOBFREELISTSIZE 100
|
||||
|
||||
|
||||
#define INFINITE_THREADS -1
|
||||
|
||||
|
||||
#define EMAXTHREADS (-8 & 1<<29)
|
||||
|
||||
/* Invalid Policy */
|
||||
|
||||
/*! Invalid Policy */
|
||||
#define INVALID_POLICY (-9 & 1<<29)
|
||||
|
||||
/* Invalid JOB Id */
|
||||
|
||||
/*! Invalid JOB Id */
|
||||
#define INVALID_JOB_ID (-2 & 1<<29)
|
||||
|
||||
typedef enum duration {SHORT_TERM,PERSISTENT} Duration;
|
||||
|
||||
typedef enum priority {LOW_PRIORITY,
|
||||
MED_PRIORITY,
|
||||
HIGH_PRIORITY} ThreadPriority;
|
||||
typedef enum duration {
|
||||
SHORT_TERM,
|
||||
PERSISTENT
|
||||
} Duration;
|
||||
|
||||
#define DEFAULT_PRIORITY MED_PRIORITY /* default priority used by TPJobInit */
|
||||
#define DEFAULT_MIN_THREADS 1 /* default minimum used by TPAttrInit */
|
||||
#define DEFAULT_MAX_THREADS 10 /* default max used by TPAttrInit */
|
||||
#define DEFAULT_JOBS_PER_THREAD 10 /* default jobs per thread used by TPAttrInit */
|
||||
#define DEFAULT_STARVATION_TIME 500 /* default starvation time used by TPAttrInit */
|
||||
#define DEFAULT_IDLE_TIME 10 * 1000 /* default idle time used by TPAttrInit */
|
||||
#define DEFAULT_FREE_ROUTINE NULL /* default free routine used TPJobInit */
|
||||
#define DEFAULT_MAX_JOBS_TOTAL 100 /* default max jobs used TPAttrInit */
|
||||
|
||||
/* Statistics */
|
||||
/* always include stats because code change is minimal */
|
||||
typedef enum priority {
|
||||
LOW_PRIORITY,
|
||||
MED_PRIORITY,
|
||||
HIGH_PRIORITY
|
||||
} ThreadPriority;
|
||||
|
||||
|
||||
/*! default priority used by TPJobInit */
|
||||
#define DEFAULT_PRIORITY MED_PRIORITY
|
||||
|
||||
|
||||
/*! default minimum used by TPAttrInit */
|
||||
#define DEFAULT_MIN_THREADS 1
|
||||
|
||||
|
||||
/*! default max used by TPAttrInit */
|
||||
#define DEFAULT_MAX_THREADS 10
|
||||
|
||||
|
||||
/*! default jobs per thread used by TPAttrInit */
|
||||
#define DEFAULT_JOBS_PER_THREAD 10
|
||||
|
||||
|
||||
/*! default starvation time used by TPAttrInit */
|
||||
#define DEFAULT_STARVATION_TIME 500
|
||||
|
||||
|
||||
/*! default idle time used by TPAttrInit */
|
||||
#define DEFAULT_IDLE_TIME 10 * 1000
|
||||
|
||||
|
||||
/*! default free routine used TPJobInit */
|
||||
#define DEFAULT_FREE_ROUTINE NULL
|
||||
|
||||
|
||||
/*! default max jobs used TPAttrInit */
|
||||
#define DEFAULT_MAX_JOBS_TOTAL 100
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Statistics.
|
||||
*
|
||||
* Always include stats because code change is minimal.
|
||||
*/
|
||||
#define STATS 1
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
|
||||
#include "LinkedList.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <time.h>
|
||||
#include <winsock2.h>
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest; /* minutes W of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||
#else /* WIN32 */
|
||||
#include <sys/time.h> /* for gettimeofday() */
|
||||
#endif
|
||||
|
||||
#include "FreeList.h"
|
||||
|
||||
#include "ithread.h"
|
||||
#include <errno.h>
|
||||
|
||||
#define EXPORT
|
||||
|
||||
typedef int PolicyType;
|
||||
|
||||
|
||||
#define DEFAULT_POLICY SCHED_OTHER
|
||||
#define DEFAULT_SCHED_PARAM 0 /* default priority */
|
||||
|
||||
|
||||
/*! Default priority */
|
||||
#define DEFAULT_SCHED_PARAM 0
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: free_routine
|
||||
@ -112,6 +161,7 @@ typedef int PolicyType;
|
||||
*****************************************************************************/
|
||||
typedef void (*free_routine)(void *arg);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ThreadPoolAttr
|
||||
*
|
||||
@ -145,6 +195,7 @@ typedef struct THREADPOOLATTR
|
||||
PolicyType schedPolicy;
|
||||
} ThreadPoolAttr;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ThreadPool
|
||||
*
|
||||
@ -161,13 +212,13 @@ typedef struct THREADPOOLJOB
|
||||
int jobId;
|
||||
} ThreadPoolJob;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ThreadPoolStats
|
||||
*
|
||||
* Description:
|
||||
* Structure to hold statistics
|
||||
*****************************************************************************/
|
||||
|
||||
typedef struct TPOOLSTATS
|
||||
{
|
||||
double totalTimeHQ;
|
||||
@ -192,26 +243,21 @@ typedef struct TPOOLSTATS
|
||||
} ThreadPoolStats;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ThreadPool
|
||||
/*!
|
||||
* \brief A thread pool similar to the thread pool in the UPnP SDK.
|
||||
*
|
||||
* Description:
|
||||
* A thread pool similar to the thread pool in the UPnP SDK.
|
||||
* Allows jobs to be scheduled for running by threads in a
|
||||
* thread pool. The thread pool is initialized with a
|
||||
* minimum and maximum thread number as well as a
|
||||
* max idle time
|
||||
* and a jobs per thread ratio. If a worker thread waits the whole
|
||||
* max idle time without receiving a job and the thread pool
|
||||
* currently has more threads running than the minimum
|
||||
* then the worker thread will exit. If when
|
||||
* scheduling a job the current job to thread ratio
|
||||
* becomes greater than the set ratio and the thread pool currently has
|
||||
* less than the maximum threads then a new thread will
|
||||
* be created.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
* Allows jobs to be scheduled for running by threads in a
|
||||
* thread pool. The thread pool is initialized with a
|
||||
* minimum and maximum thread number as well as a max idle time
|
||||
* and a jobs per thread ratio. If a worker thread waits the whole
|
||||
* max idle time without receiving a job and the thread pool
|
||||
* currently has more threads running than the minimum
|
||||
* then the worker thread will exit. If when
|
||||
* scheduling a job the current job to thread ratio
|
||||
* becomes greater than the set ratio and the thread pool currently has
|
||||
* less than the maximum threads then a new thread will
|
||||
* be created.
|
||||
*/
|
||||
typedef struct THREADPOOL
|
||||
{
|
||||
ithread_mutex_t mutex; /* mutex to protect job qs */
|
||||
@ -235,7 +281,6 @@ typedef struct THREADPOOL
|
||||
} ThreadPool;
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolInit
|
||||
*
|
||||
@ -274,6 +319,7 @@ typedef struct THREADPOOL
|
||||
*****************************************************************************/
|
||||
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolAddPersistent
|
||||
*
|
||||
@ -296,6 +342,7 @@ int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||
*****************************************************************************/
|
||||
int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolGetAttr
|
||||
*
|
||||
@ -310,6 +357,8 @@ int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolSetAttr
|
||||
*
|
||||
@ -325,6 +374,7 @@ int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
|
||||
*****************************************************************************/
|
||||
int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolAdd
|
||||
*
|
||||
@ -344,6 +394,7 @@ int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
|
||||
*****************************************************************************/
|
||||
int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolRemove
|
||||
*
|
||||
@ -396,6 +447,7 @@ int ThreadPoolShutdown(ThreadPool *tp);
|
||||
*****************************************************************************/
|
||||
int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPJobSetPriority
|
||||
*
|
||||
@ -409,6 +461,7 @@ int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
|
||||
*****************************************************************************/
|
||||
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPJobSetFreeFunction
|
||||
*
|
||||
@ -422,6 +475,7 @@ int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
|
||||
*****************************************************************************/
|
||||
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrInit
|
||||
*
|
||||
@ -435,6 +489,7 @@ int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
|
||||
*****************************************************************************/
|
||||
int TPAttrInit(ThreadPoolAttr *attr);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetMaxThreads
|
||||
*
|
||||
@ -448,6 +503,7 @@ int TPAttrInit(ThreadPoolAttr *attr);
|
||||
*****************************************************************************/
|
||||
int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetMinThreads
|
||||
*
|
||||
@ -461,6 +517,7 @@ int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
|
||||
*****************************************************************************/
|
||||
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetIdleTime
|
||||
*
|
||||
@ -473,6 +530,7 @@ int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
|
||||
*****************************************************************************/
|
||||
int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetJobsPerThread
|
||||
*
|
||||
@ -486,6 +544,7 @@ int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
|
||||
*****************************************************************************/
|
||||
int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetStarvationTime
|
||||
*
|
||||
@ -499,6 +558,7 @@ int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
|
||||
*****************************************************************************/
|
||||
int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TPAttrSetSchedPolicy
|
||||
*
|
||||
@ -526,6 +586,7 @@ int TPAttrSetSchedPolicy(ThreadPoolAttr *attr, PolicyType schedPolicy);
|
||||
*****************************************************************************/
|
||||
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ThreadPoolGetStats
|
||||
*
|
||||
@ -540,18 +601,20 @@ int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
|
||||
* Always returns 0.
|
||||
*****************************************************************************/
|
||||
#ifdef STATS
|
||||
EXPORT int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats);
|
||||
EXPORT_SPEC int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats);
|
||||
|
||||
EXPORT void ThreadPoolPrintStats(ThreadPoolStats *stats);
|
||||
EXPORT_SPEC void ThreadPoolPrintStats(ThreadPoolStats *stats);
|
||||
#else
|
||||
static UPNP_INLINE int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats) {}
|
||||
|
||||
static UPNP_INLINE void ThreadPoolPrintStats(ThreadPoolStats *stats) {}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ThreadPool */
|
||||
|
||||
#endif /* THREADPOOL_H */
|
||||
|
||||
|
@ -29,160 +29,139 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#ifndef TIMERTHREAD_H
|
||||
#define TIMERTHREAD_H
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "FreeList.h"
|
||||
#include "ithread.h"
|
||||
#include "LinkedList.h"
|
||||
#include "FreeList.h"
|
||||
#include "ThreadPool.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define INVALID_EVENT_ID (-10 & 1<<29)
|
||||
|
||||
|
||||
/* Timeout Types */
|
||||
/* absolute means in seconds from Jan 1, 1970 */
|
||||
/* relative means in seconds from current time */
|
||||
typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: TimerThread
|
||||
*
|
||||
* Description:
|
||||
* 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
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*!
|
||||
* 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.
|
||||
*/
|
||||
typedef struct TIMERTHREAD
|
||||
{
|
||||
ithread_mutex_t mutex;
|
||||
ithread_cond_t condition;
|
||||
int lastEventId;
|
||||
LinkedList eventQ;
|
||||
int shutdown;
|
||||
FreeList freeEvents;
|
||||
ThreadPool *tp;
|
||||
ithread_mutex_t mutex;
|
||||
ithread_cond_t condition;
|
||||
int lastEventId;
|
||||
LinkedList eventQ;
|
||||
int shutdown;
|
||||
FreeList freeEvents;
|
||||
ThreadPool *tp;
|
||||
} TimerThread;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: TimerEvent
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Struct to contain information for a timer event.
|
||||
* Internal to the TimerThread
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*!
|
||||
* Struct to contain information for a timer event.
|
||||
*
|
||||
* Internal to the TimerThread.
|
||||
*/
|
||||
typedef struct TIMEREVENT
|
||||
{
|
||||
ThreadPoolJob job;
|
||||
time_t eventTime; /* absolute time for event in seconds since Jan 1, 1970 */
|
||||
Duration persistent; /* long term or short term job */
|
||||
int id;
|
||||
ThreadPoolJob job;
|
||||
/*! [in] Absolute time for event in seconds since Jan 1, 1970. */
|
||||
time_t eventTime;
|
||||
/*! [in] Long term or short term job. */
|
||||
Duration persistent;
|
||||
int id;
|
||||
} TimerEvent;
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Function: TimerThreadInit
|
||||
*
|
||||
* Description:
|
||||
* Initializes and starts timer thread.
|
||||
/*!
|
||||
* \brief Initializes and starts timer thread.
|
||||
*
|
||||
* Parameters:
|
||||
* timer - valid timer thread pointer.
|
||||
* tp - valid thread pool to use. Must be
|
||||
* started. Must be valid for lifetime
|
||||
* of timer. Timer must be shutdown
|
||||
* BEFORE thread pool.
|
||||
* Return:
|
||||
* 0 on success, nonzero on failure
|
||||
* Returns error from ThreadPoolAddPersistent on failure.
|
||||
*
|
||||
************************************************************************/
|
||||
int TimerThreadInit(TimerThread *timer,
|
||||
ThreadPool *tp);
|
||||
* \return 0 on success, nonzero on failure. Returns error from
|
||||
* ThreadPoolAddPersistent on failure.
|
||||
*/
|
||||
int TimerThreadInit(
|
||||
/*! [in] Valid timer thread pointer. */
|
||||
TimerThread *timer,
|
||||
/*! [in] Valid thread pool to use. Must be started. Must be valid for
|
||||
* lifetime of timer. Timer must be shutdown BEFORE thread pool. */
|
||||
ThreadPool *tp);
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Function: TimerThreadSchedule
|
||||
*
|
||||
* Description:
|
||||
* Schedules an event to run at a specified time.
|
||||
/*!
|
||||
* \brief Schedules an event to run at a specified time.
|
||||
*
|
||||
* Parameters:
|
||||
* timer - valid timer thread pointer.
|
||||
* time_t - time of event.
|
||||
* either in absolute seconds,
|
||||
* or relative seconds in the future.
|
||||
* timeoutType - either ABS_SEC, or REL_SEC.
|
||||
* if REL_SEC, then the event
|
||||
* will be scheduled at the
|
||||
* current time + REL_SEC.
|
||||
* job-> valid Thread pool job with following fields
|
||||
* func - function to schedule
|
||||
* arg - argument to function
|
||||
* priority - priority of job.
|
||||
*
|
||||
* id - id of timer event. (out, can be null)
|
||||
* Return:
|
||||
* 0 on success, nonzero on failure
|
||||
* EOUTOFMEM if not enough memory to schedule job.
|
||||
*
|
||||
************************************************************************/
|
||||
int TimerThreadSchedule(TimerThread* timer,
|
||||
time_t time,
|
||||
TimeoutType type,
|
||||
ThreadPoolJob *job,
|
||||
Duration duration,
|
||||
int *id);
|
||||
* \return 0 on success, nonzero on failure, EOUTOFMEM if not enough memory
|
||||
* to schedule job.
|
||||
*/
|
||||
int TimerThreadSchedule(
|
||||
/*! [in] Valid timer thread pointer. */
|
||||
TimerThread* timer,
|
||||
/*! [in] time of event. Either in absolute seconds, or relative
|
||||
* seconds in the future. */
|
||||
time_t time,
|
||||
/*! [in] either ABS_SEC, or REL_SEC. If REL_SEC, then the event
|
||||
* will be scheduled at the current time + REL_SEC. */
|
||||
TimeoutType type,
|
||||
/*! [in] Valid Thread pool job with following fields. */
|
||||
ThreadPoolJob *job,
|
||||
/*! [in] . */
|
||||
Duration duration,
|
||||
/*! [in] Id of timer event. (out, can be null). */
|
||||
int *id);
|
||||
|
||||
/************************************************************************
|
||||
* Function: TimerThreadRemove
|
||||
*
|
||||
* Description:
|
||||
* Removes an event from the timer Q.
|
||||
* Events can only be removed
|
||||
* before they have been placed in the
|
||||
* thread pool.
|
||||
*
|
||||
* Parameters:
|
||||
* timer - valid timer thread pointer.
|
||||
* id - id of event to remove.
|
||||
* ThreadPoolJob *out - space for thread pool job.
|
||||
* Return:
|
||||
* 0 on success,
|
||||
* INVALID_EVENT_ID on failure
|
||||
*
|
||||
************************************************************************/
|
||||
int TimerThreadRemove(TimerThread *timer,
|
||||
int id,
|
||||
ThreadPoolJob *out);
|
||||
|
||||
/************************************************************************
|
||||
* Function: TimerThreadShutdown
|
||||
*
|
||||
* Description:
|
||||
* 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:
|
||||
* returns 0 if succesfull,
|
||||
* nonzero otherwise.
|
||||
* Always returns 0.
|
||||
***********************************************************************/
|
||||
int TimerThreadShutdown(TimerThread *timer);
|
||||
/*!
|
||||
* \brief Removes an event from the timer Q.
|
||||
*
|
||||
* Events can only be removed before they have been placed in the thread pool.
|
||||
*
|
||||
* \return 0 on success, INVALID_EVENT_ID on failure.
|
||||
*/
|
||||
int TimerThreadRemove(
|
||||
/*! [in] Valid timer thread pointer. */
|
||||
TimerThread *timer,
|
||||
/*! [in] Id of event to remove. */
|
||||
int id,
|
||||
/*! [in] Space for thread pool job. */
|
||||
ThreadPoolJob *out);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Shutdown the timer thread.
|
||||
*
|
||||
* Events scheduled in the future will NOT be run.
|
||||
*
|
||||
* Timer thread should be shutdown BEFORE it's associated thread pool.
|
||||
*
|
||||
* \return 0 if succesfull, nonzero otherwise. Always returns 0.
|
||||
*/
|
||||
int TimerThreadShutdown(
|
||||
/*! [in] Valid timer thread pointer. */
|
||||
TimerThread *timer);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -34,6 +34,11 @@
|
||||
#define ITHREADH
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "UpnpGlobal.h" /* For EXPORT_SPEC */
|
||||
|
||||
|
||||
|
@ -1,68 +1,69 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
#include "TimerThread.h"
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Function: FreeTimerEvent
|
||||
*
|
||||
* Description:
|
||||
* Deallocates a dynamically allocated TimerEvent.
|
||||
* Parameters:
|
||||
* TimerEvent *event - must be allocated with CreateTimerEvent
|
||||
*****************************************************************************/
|
||||
static void
|
||||
FreeTimerEvent( TimerThread * timer,
|
||||
TimerEvent * event )
|
||||
|
||||
/*!
|
||||
* \brief Deallocates a dynamically allocated TimerEvent.
|
||||
*/
|
||||
static void FreeTimerEvent(
|
||||
/*! [in] Valid timer thread pointer. */
|
||||
TimerThread *timer,
|
||||
/*! [in] Must be allocated with CreateTimerEvent*/
|
||||
TimerEvent *event)
|
||||
{
|
||||
assert(timer != NULL);
|
||||
|
||||
assert( timer != NULL );
|
||||
|
||||
FreeListFree( &timer->freeEvents, event );
|
||||
FreeListFree(&timer->freeEvents, event);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: TimerThreadWorker
|
||||
|
||||
/*!
|
||||
* \brief Implements timer thread.
|
||||
*
|
||||
* Description:
|
||||
* Implements timer thread.
|
||||
* Waits for next event to occur and schedules
|
||||
* associated job into threadpool.
|
||||
* Internal Only.
|
||||
* Parameters:
|
||||
* void * arg -> is cast to TimerThread *
|
||||
*****************************************************************************/
|
||||
static void *
|
||||
TimerThreadWorker( void *arg )
|
||||
* Waits for next event to occur and schedules associated job into threadpool.
|
||||
*/
|
||||
static void *TimerThreadWorker(
|
||||
/*! [in] arg is cast to (TimerThread *). */
|
||||
void *arg)
|
||||
{
|
||||
TimerThread *timer = ( TimerThread * ) arg;
|
||||
ListNode *head = NULL;
|
||||
@ -81,19 +82,14 @@ TimerThreadWorker( void *arg )
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
|
||||
//mutex should always be locked at top of loop
|
||||
|
||||
//Check for shutdown
|
||||
|
||||
if( timer->shutdown )
|
||||
{
|
||||
|
||||
timer->shutdown = 0;
|
||||
ithread_cond_signal( &timer->condition );
|
||||
ithread_mutex_unlock( &timer->mutex );
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
nextEvent = NULL;
|
||||
@ -102,7 +98,6 @@ TimerThreadWorker( void *arg )
|
||||
if( timer->eventQ.size > 0 )
|
||||
{
|
||||
head = ListHead( &timer->eventQ );
|
||||
|
||||
nextEvent = ( TimerEvent * ) head->item;
|
||||
nextEventTime = nextEvent->eventTime;
|
||||
}
|
||||
@ -110,54 +105,42 @@ TimerThreadWorker( void *arg )
|
||||
currentTime = time( NULL );
|
||||
|
||||
//If time has elapsed, schedule job
|
||||
|
||||
if( ( nextEvent != NULL ) && ( currentTime >= nextEventTime ) )
|
||||
{
|
||||
|
||||
if( nextEvent->persistent ) {
|
||||
|
||||
ThreadPoolAddPersistent( timer->tp, &nextEvent->job,
|
||||
&tempId );
|
||||
} else {
|
||||
|
||||
ThreadPoolAdd( timer->tp, &nextEvent->job, &tempId );
|
||||
}
|
||||
|
||||
ListDelNode( &timer->eventQ, head, 0 );
|
||||
FreeTimerEvent( timer, nextEvent );
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if( nextEvent != NULL ) {
|
||||
timeToWait.tv_nsec = 0;
|
||||
timeToWait.tv_sec = nextEvent->eventTime;
|
||||
|
||||
ithread_cond_timedwait( &timer->condition, &timer->mutex,
|
||||
&timeToWait );
|
||||
|
||||
} else {
|
||||
ithread_cond_wait( &timer->condition, &timer->mutex );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: CalculateEventTime
|
||||
|
||||
/*!
|
||||
* \brief Calculates the appropriate timeout in absolute seconds
|
||||
* since Jan 1, 1970.
|
||||
*
|
||||
* Description:
|
||||
* Calculates the appropriate timeout in absolute seconds since
|
||||
* Jan 1, 1970
|
||||
* Internal Only.
|
||||
* Parameters:
|
||||
* time_t *timeout - timeout
|
||||
*
|
||||
*****************************************************************************/
|
||||
static int
|
||||
CalculateEventTime( time_t * timeout,
|
||||
TimeoutType type )
|
||||
* \return
|
||||
*/
|
||||
static int CalculateEventTime(
|
||||
/*! [in] Timeout. */
|
||||
time_t *timeout,
|
||||
/*! [in] Timeout type. */
|
||||
TimeoutType type)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
@ -175,29 +158,22 @@ CalculateEventTime( time_t * timeout,
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: CreateTimerEvent
|
||||
/*!
|
||||
* \brief Creates a Timer Event. (Dynamically allocated).
|
||||
*
|
||||
* Description:
|
||||
* Creates a Timer Event. (Dynamically allocated)
|
||||
* Internal to timer thread.
|
||||
* Parameters:
|
||||
* func - thread function to run.
|
||||
* arg - argument to function.
|
||||
* priority - priority of job.
|
||||
* eventTime - the absoule time of the event
|
||||
* in seconds from Jan, 1970
|
||||
* id - id of job
|
||||
*
|
||||
* Returns:
|
||||
* TimerEvent * on success, NULL on failure.
|
||||
****************************************************************************/
|
||||
static TimerEvent *
|
||||
CreateTimerEvent( TimerThread * timer,
|
||||
ThreadPoolJob * job,
|
||||
Duration persistent,
|
||||
time_t eventTime,
|
||||
int id )
|
||||
* \return (TimerEvent *) on success, NULL on failure.
|
||||
*/
|
||||
static TimerEvent *CreateTimerEvent(
|
||||
/*! [in] Valid timer thread pointer. */
|
||||
TimerThread *timer,
|
||||
/*! [in] . */
|
||||
ThreadPoolJob *job,
|
||||
/*! [in] . */
|
||||
Duration persistent,
|
||||
/*! [in] The absoule time of the event in seconds from Jan, 1970. */
|
||||
time_t eventTime,
|
||||
/*! [in] Id of job. */
|
||||
int id)
|
||||
{
|
||||
TimerEvent *temp = NULL;
|
||||
|
||||
@ -215,25 +191,8 @@ CreateTimerEvent( TimerThread * timer,
|
||||
return temp;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function: TimerThreadInit
|
||||
*
|
||||
* Description:
|
||||
* Initializes and starts timer thread.
|
||||
*
|
||||
* Parameters:
|
||||
* timer - valid timer thread pointer.
|
||||
* tp - valid thread pool to use. Must be
|
||||
* started. Must be valid for lifetime
|
||||
* of timer. Timer must be shutdown
|
||||
* BEFORE thread pool.
|
||||
* Return:
|
||||
* 0 on success, nonzero on failure
|
||||
* Returns error from ThreadPoolAddPersistent if failure.
|
||||
************************************************************************/
|
||||
int
|
||||
TimerThreadInit( TimerThread * timer,
|
||||
ThreadPool * tp )
|
||||
|
||||
int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
|
||||
{
|
||||
|
||||
int rc = 0;
|
||||
@ -290,37 +249,14 @@ TimerThreadInit( TimerThread * timer,
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function: TimerThreadSchedule
|
||||
*
|
||||
* Description:
|
||||
* Schedules an event to run at a specified time.
|
||||
*
|
||||
* Parameters:
|
||||
* timer - valid timer thread pointer.
|
||||
* time_t - time of event.
|
||||
* either in absolute seconds,
|
||||
* or relative seconds in the future.
|
||||
* timeoutType - either ABS_SEC, or REL_SEC.
|
||||
* if REL_SEC, then the event
|
||||
* will be scheduled at the
|
||||
* current time + REL_SEC.
|
||||
*
|
||||
* func - function to schedule
|
||||
* arg - argument to function
|
||||
* priority - priority of job.
|
||||
* id - id of timer event. (out)
|
||||
* Return:
|
||||
* 0 on success, nonzero on failure
|
||||
* EOUTOFMEM if not enough memory to schedule job
|
||||
************************************************************************/
|
||||
int
|
||||
TimerThreadSchedule( TimerThread * timer,
|
||||
time_t timeout,
|
||||
TimeoutType type,
|
||||
ThreadPoolJob * job,
|
||||
Duration duration,
|
||||
int *id )
|
||||
|
||||
int TimerThreadSchedule(
|
||||
TimerThread *timer,
|
||||
time_t timeout,
|
||||
TimeoutType type,
|
||||
ThreadPoolJob *job,
|
||||
Duration duration,
|
||||
int *id)
|
||||
{
|
||||
|
||||
int rc = EOUTOFMEM;
|
||||
@ -394,28 +330,11 @@ TimerThreadSchedule( TimerThread * timer,
|
||||
return rc;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function: TimerThreadRemove
|
||||
*
|
||||
* Description:
|
||||
* Removes an event from the timer Q.
|
||||
* Events can only be removed
|
||||
* before they have been placed in the
|
||||
* thread pool.
|
||||
*
|
||||
* Parameters:
|
||||
* timer - valid timer thread pointer.
|
||||
* id - id of event to remove.
|
||||
* out - space for returned job (Can be NULL)
|
||||
* Return:
|
||||
* 0 on success.
|
||||
* INVALID_EVENT_ID on error.
|
||||
*
|
||||
************************************************************************/
|
||||
int
|
||||
TimerThreadRemove( TimerThread * timer,
|
||||
int id,
|
||||
ThreadPoolJob * out )
|
||||
|
||||
int TimerThreadRemove(
|
||||
TimerThread *timer,
|
||||
int id,
|
||||
ThreadPoolJob *out)
|
||||
{
|
||||
int rc = INVALID_EVENT_ID;
|
||||
ListNode *tempNode = NULL;
|
||||
@ -450,21 +369,8 @@ TimerThreadRemove( TimerThread * timer,
|
||||
return rc;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Function: TimerThreadShutdown
|
||||
*
|
||||
* Description:
|
||||
* 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:
|
||||
* returns 0 if succesfull,
|
||||
* nonzero otherwise.
|
||||
* Always returns 0.
|
||||
***********************************************************************/
|
||||
int
|
||||
TimerThreadShutdown( TimerThread * timer )
|
||||
|
||||
int TimerThreadShutdown(TimerThread *timer)
|
||||
{
|
||||
ListNode *tempNode2 = NULL;
|
||||
ListNode *tempNode = NULL;
|
||||
@ -517,3 +423,4 @@ TimerThreadShutdown( TimerThread * timer )
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,6 @@
|
||||
*/
|
||||
#define EXPORT_SPEC
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Declares an inline function.
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**************************************************************************
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
@ -27,7 +27,7 @@
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************/
|
||||
******************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -1,65 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*
|
||||
* \brief Contains a function for freeing the memory associated with a upnp
|
||||
* time out event.
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
* Purpose: This file contains a function for freeing the memory associated
|
||||
* wuth a upnp time out event.
|
||||
************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include "upnp_timeout.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/************************************************************************
|
||||
* Function : free_upnp_timeout
|
||||
*
|
||||
* Parameters :
|
||||
* upnp_timeout *event ; Event which needs to be freed
|
||||
*
|
||||
* Description : Free memory associated with event and memory for any
|
||||
* sub-elements
|
||||
*
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void
|
||||
free_upnp_timeout( upnp_timeout * event )
|
||||
#include <stdlib.h> /* for free() */
|
||||
|
||||
|
||||
void free_upnp_timeout(upnp_timeout *event)
|
||||
{
|
||||
|
||||
if( event ) {
|
||||
if( event->Event )
|
||||
free( event->Event );
|
||||
free( event );
|
||||
|
||||
}
|
||||
if (event) {
|
||||
if (event->Event) {
|
||||
free(event->Event);
|
||||
}
|
||||
free(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,58 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2000-2003 Intel Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
// * Neither name of Intel Corporation nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* - Neither name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _UPNPTIMEOUTH_
|
||||
#define _UPNPTIMEOUTH_
|
||||
|
||||
#ifndef UPNPTIMEOUT_H
|
||||
#define UPNPTIMEOUT_H
|
||||
|
||||
|
||||
/*!
|
||||
* \file
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
* The upnp_timeout structure definition.
|
||||
*/
|
||||
typedef struct UPNP_TIMEOUT {
|
||||
int EventType;
|
||||
int handle;
|
||||
int eventId;
|
||||
void *Event;
|
||||
int EventType;
|
||||
int handle;
|
||||
int eventId;
|
||||
void *Event;
|
||||
} upnp_timeout;
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Function : free_upnp_timeout
|
||||
*
|
||||
* Parameters :
|
||||
* upnp_timeout *event ; Event which needs to be freed
|
||||
*
|
||||
* Description : Free memory associated with event and memory for any
|
||||
* sub-elements
|
||||
*
|
||||
* Return : void ;
|
||||
*
|
||||
* Note :
|
||||
************************************************************************/
|
||||
void free_upnp_timeout(upnp_timeout *event);
|
||||
/*!
|
||||
* \brief Free memory associated with event and memory for any sub-elements.
|
||||
*/
|
||||
void free_upnp_timeout(
|
||||
/*! [in] Event which needs to be freed. */
|
||||
upnp_timeout *event);
|
||||
|
||||
|
||||
#endif /* UPNPTIMEOUT_H */
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user