git-svn-id: https://pupnp.svn.sourceforge.net/svnroot/pupnp/trunk@432 119443c7-1b9e-41f8-b6fc-b9c35fce742c
This commit is contained in:
Marcelo Roberto Jimenez 2008-06-10 04:31:44 +00:00
parent 7f4bac9727
commit 5c008e3634
10 changed files with 476 additions and 491 deletions

View File

@ -29,14 +29,24 @@
* *
******************************************************************************/ ******************************************************************************/
#ifndef FREE_LIST_H #ifndef FREE_LIST_H
#define FREE_LIST_H #define FREE_LIST_H
/*!
* \file
*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "ithread.h" #include "ithread.h"
#include <errno.h> #include <errno.h>
/**************************************************************************** /****************************************************************************

View File

@ -29,21 +29,32 @@
* *
******************************************************************************/ ******************************************************************************/
#ifndef LINKED_LIST_H #ifndef LINKED_LIST_H
#define LINKED_LIST_H #define LINKED_LIST_H
/*!
* \file
*/
#include "FreeList.h" #include "FreeList.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define EOUTOFMEM (-7 & 1<<29) #define EOUTOFMEM (-7 & 1<<29)
#define FREELISTSIZE 100 #define FREELISTSIZE 100
#define LIST_SUCCESS 1 #define LIST_SUCCESS 1
#define LIST_FAIL 0 #define LIST_FAIL 0
/**************************************************************************** /****************************************************************************
* Name: free_routine * Name: free_routine
* *
@ -52,6 +63,7 @@ extern "C" {
*****************************************************************************/ *****************************************************************************/
typedef void (*free_function)(void *arg); typedef void (*free_function)(void *arg);
/**************************************************************************** /****************************************************************************
* Name: cmp_routine * Name: cmp_routine
* *
@ -61,6 +73,7 @@ typedef void (*free_function)(void *arg);
*****************************************************************************/ *****************************************************************************/
typedef int (*cmp_routine)(void *itemA,void *itemB); typedef int (*cmp_routine)(void *itemA,void *itemB);
/**************************************************************************** /****************************************************************************
* Name: ListNode * Name: ListNode
* *
@ -75,6 +88,7 @@ typedef struct LISTNODE
void *item; void *item;
} ListNode; } ListNode;
/**************************************************************************** /****************************************************************************
* Name: LinkedList * Name: LinkedList
* *
@ -104,6 +118,7 @@ typedef struct LINKEDLIST
cmp_routine cmp_func; /* compare function to use */ cmp_routine cmp_func; /* compare function to use */
} LinkedList; } LinkedList;
/**************************************************************************** /****************************************************************************
* Function: ListInit * Function: ListInit
* *
@ -119,6 +134,7 @@ typedef struct LINKEDLIST
*****************************************************************************/ *****************************************************************************/
int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func); int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
/**************************************************************************** /****************************************************************************
* Function: ListAddHead * Function: ListAddHead
* *
@ -135,6 +151,7 @@ int ListInit(LinkedList *list,cmp_routine cmp_func, free_function free_func);
*****************************************************************************/ *****************************************************************************/
ListNode *ListAddHead(LinkedList *list, void *item); ListNode *ListAddHead(LinkedList *list, void *item);
/**************************************************************************** /****************************************************************************
* Function: ListAddTail * Function: ListAddTail
* *
@ -151,6 +168,7 @@ ListNode *ListAddHead(LinkedList *list, void *item);
*****************************************************************************/ *****************************************************************************/
ListNode *ListAddTail(LinkedList *list, void *item); ListNode *ListAddTail(LinkedList *list, void *item);
/**************************************************************************** /****************************************************************************
* Function: ListAddAfter * Function: ListAddAfter
* *
@ -205,6 +223,7 @@ ListNode *ListAddBefore(LinkedList *list,void *item, ListNode *anode);
*****************************************************************************/ *****************************************************************************/
void *ListDelNode(LinkedList *list,ListNode *dnode, int freeItem); void *ListDelNode(LinkedList *list,ListNode *dnode, int freeItem);
/**************************************************************************** /****************************************************************************
* Function: ListDestroy * Function: ListDestroy
* *
@ -240,6 +259,7 @@ int ListDestroy(LinkedList *list, int freeItem);
*****************************************************************************/ *****************************************************************************/
ListNode* ListHead(LinkedList *list); ListNode* ListHead(LinkedList *list);
/**************************************************************************** /****************************************************************************
* Function: ListTail * Function: ListTail
* *
@ -256,6 +276,7 @@ ListNode* ListHead(LinkedList *list);
*****************************************************************************/ *****************************************************************************/
ListNode* ListTail(LinkedList *list); ListNode* ListTail(LinkedList *list);
/**************************************************************************** /****************************************************************************
* Function: ListNext * Function: ListNext
* *
@ -272,6 +293,7 @@ ListNode* ListTail(LinkedList *list);
*****************************************************************************/ *****************************************************************************/
ListNode* ListNext(LinkedList *list, ListNode * node); ListNode* ListNext(LinkedList *list, ListNode * node);
/**************************************************************************** /****************************************************************************
* Function: ListPrev * Function: ListPrev
* *
@ -288,6 +310,7 @@ ListNode* ListNext(LinkedList *list, ListNode * node);
*****************************************************************************/ *****************************************************************************/
ListNode* ListPrev(LinkedList *list, ListNode * node); ListNode* ListPrev(LinkedList *list, ListNode * node);
/**************************************************************************** /****************************************************************************
* Function: ListFind * Function: ListFind
* *
@ -307,6 +330,7 @@ ListNode* ListPrev(LinkedList *list, ListNode * node);
*****************************************************************************/ *****************************************************************************/
ListNode* ListFind(LinkedList *list, ListNode *start, void * item); ListNode* ListFind(LinkedList *list, ListNode *start, void * item);
/**************************************************************************** /****************************************************************************
* Function: ListSize * Function: ListSize
* *

View File

@ -29,80 +29,129 @@
* *
******************************************************************************/ ******************************************************************************/
#ifndef THREADPOOL_H #ifndef THREADPOOL_H
#define THREADPOOL_H #define THREADPOOL_H
#ifdef UPNP_USE_MSVCPP
#define UPNP_INLINE /*!
#else * \file
#define UPNP_INLINE inline */
#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 #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* Size of job free list */
/*! Size of job free list */
#define JOBFREELISTSIZE 100 #define JOBFREELISTSIZE 100
#define INFINITE_THREADS -1 #define INFINITE_THREADS -1
#define EMAXTHREADS (-8 & 1<<29) #define EMAXTHREADS (-8 & 1<<29)
/* Invalid Policy */
/*! Invalid Policy */
#define INVALID_POLICY (-9 & 1<<29) #define INVALID_POLICY (-9 & 1<<29)
/* Invalid JOB Id */
/*! Invalid JOB Id */
#define INVALID_JOB_ID (-2 & 1<<29) #define INVALID_JOB_ID (-2 & 1<<29)
typedef enum duration {SHORT_TERM,PERSISTENT} Duration;
typedef enum priority {LOW_PRIORITY, typedef enum duration {
MED_PRIORITY, SHORT_TERM,
HIGH_PRIORITY} ThreadPriority; 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 */ typedef enum priority {
/* always include stats because code change is minimal */ 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 #define STATS 1
#ifdef _DEBUG #ifdef _DEBUG
#define DEBUG 1 #define DEBUG 1
#endif #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; typedef int PolicyType;
#define DEFAULT_POLICY SCHED_OTHER #define DEFAULT_POLICY SCHED_OTHER
#define DEFAULT_SCHED_PARAM 0 /* default priority */
/*! Default priority */
#define DEFAULT_SCHED_PARAM 0
/**************************************************************************** /****************************************************************************
* Name: free_routine * Name: free_routine
@ -112,6 +161,7 @@ typedef int PolicyType;
*****************************************************************************/ *****************************************************************************/
typedef void (*free_routine)(void *arg); typedef void (*free_routine)(void *arg);
/**************************************************************************** /****************************************************************************
* Name: ThreadPoolAttr * Name: ThreadPoolAttr
* *
@ -145,6 +195,7 @@ typedef struct THREADPOOLATTR
PolicyType schedPolicy; PolicyType schedPolicy;
} ThreadPoolAttr; } ThreadPoolAttr;
/**************************************************************************** /****************************************************************************
* Name: ThreadPool * Name: ThreadPool
* *
@ -161,13 +212,13 @@ typedef struct THREADPOOLJOB
int jobId; int jobId;
} ThreadPoolJob; } ThreadPoolJob;
/**************************************************************************** /****************************************************************************
* Name: ThreadPoolStats * Name: ThreadPoolStats
* *
* Description: * Description:
* Structure to hold statistics * Structure to hold statistics
*****************************************************************************/ *****************************************************************************/
typedef struct TPOOLSTATS typedef struct TPOOLSTATS
{ {
double totalTimeHQ; double totalTimeHQ;
@ -192,26 +243,21 @@ typedef struct TPOOLSTATS
} ThreadPoolStats; } ThreadPoolStats;
/**************************************************************************** /*!
* Name: ThreadPool * \brief A thread pool similar to the thread pool in the UPnP SDK.
* *
* Description: * Allows jobs to be scheduled for running by threads in a
* A thread pool similar to the thread pool in the UPnP SDK. * thread pool. The thread pool is initialized with a
* Allows jobs to be scheduled for running by threads in a * minimum and maximum thread number as well as a max idle time
* thread pool. The thread pool is initialized with a * and a jobs per thread ratio. If a worker thread waits the whole
* minimum and maximum thread number as well as a * max idle time without receiving a job and the thread pool
* max idle time * currently has more threads running than the minimum
* and a jobs per thread ratio. If a worker thread waits the whole * then the worker thread will exit. If when
* max idle time without receiving a job and the thread pool * scheduling a job the current job to thread ratio
* currently has more threads running than the minimum * becomes greater than the set ratio and the thread pool currently has
* then the worker thread will exit. If when * less than the maximum threads then a new thread will
* scheduling a job the current job to thread ratio * be created.
* 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 typedef struct THREADPOOL
{ {
ithread_mutex_t mutex; /* mutex to protect job qs */ ithread_mutex_t mutex; /* mutex to protect job qs */
@ -235,7 +281,6 @@ typedef struct THREADPOOL
} ThreadPool; } ThreadPool;
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolInit * Function: ThreadPoolInit
* *
@ -274,6 +319,7 @@ typedef struct THREADPOOL
*****************************************************************************/ *****************************************************************************/
int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr); int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolAddPersistent * Function: ThreadPoolAddPersistent
* *
@ -296,6 +342,7 @@ int ThreadPoolInit(ThreadPool *tp, ThreadPoolAttr *attr);
*****************************************************************************/ *****************************************************************************/
int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId); int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolGetAttr * Function: ThreadPoolGetAttr
* *
@ -310,6 +357,8 @@ int ThreadPoolAddPersistent(ThreadPool*tp, ThreadPoolJob *job, int *jobId);
* Always returns 0. * Always returns 0.
*****************************************************************************/ *****************************************************************************/
int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out); int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolSetAttr * Function: ThreadPoolSetAttr
* *
@ -325,6 +374,7 @@ int ThreadPoolGetAttr(ThreadPool *tp, ThreadPoolAttr *out);
*****************************************************************************/ *****************************************************************************/
int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr); int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolAdd * Function: ThreadPoolAdd
* *
@ -344,6 +394,7 @@ int ThreadPoolSetAttr(ThreadPool *tp, ThreadPoolAttr *attr);
*****************************************************************************/ *****************************************************************************/
int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId); int ThreadPoolAdd (ThreadPool*tp, ThreadPoolJob *job, int *jobId);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolRemove * Function: ThreadPoolRemove
* *
@ -396,6 +447,7 @@ int ThreadPoolShutdown(ThreadPool *tp);
*****************************************************************************/ *****************************************************************************/
int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg); int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
/**************************************************************************** /****************************************************************************
* Function: TPJobSetPriority * Function: TPJobSetPriority
* *
@ -409,6 +461,7 @@ int TPJobInit(ThreadPoolJob *job, start_routine func, void *arg);
*****************************************************************************/ *****************************************************************************/
int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority); int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
/**************************************************************************** /****************************************************************************
* Function: TPJobSetFreeFunction * Function: TPJobSetFreeFunction
* *
@ -422,6 +475,7 @@ int TPJobSetPriority(ThreadPoolJob *job, ThreadPriority priority);
*****************************************************************************/ *****************************************************************************/
int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func); int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
/**************************************************************************** /****************************************************************************
* Function: TPAttrInit * Function: TPAttrInit
* *
@ -435,6 +489,7 @@ int TPJobSetFreeFunction(ThreadPoolJob *job, free_routine func);
*****************************************************************************/ *****************************************************************************/
int TPAttrInit(ThreadPoolAttr *attr); int TPAttrInit(ThreadPoolAttr *attr);
/**************************************************************************** /****************************************************************************
* Function: TPAttrSetMaxThreads * Function: TPAttrSetMaxThreads
* *
@ -448,6 +503,7 @@ int TPAttrInit(ThreadPoolAttr *attr);
*****************************************************************************/ *****************************************************************************/
int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads); int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
/**************************************************************************** /****************************************************************************
* Function: TPAttrSetMinThreads * Function: TPAttrSetMinThreads
* *
@ -461,6 +517,7 @@ int TPAttrSetMaxThreads(ThreadPoolAttr *attr, int maxThreads);
*****************************************************************************/ *****************************************************************************/
int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads); int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
/**************************************************************************** /****************************************************************************
* Function: TPAttrSetIdleTime * Function: TPAttrSetIdleTime
* *
@ -473,6 +530,7 @@ int TPAttrSetMinThreads(ThreadPoolAttr *attr, int minThreads);
*****************************************************************************/ *****************************************************************************/
int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime); int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
/**************************************************************************** /****************************************************************************
* Function: TPAttrSetJobsPerThread * Function: TPAttrSetJobsPerThread
* *
@ -486,6 +544,7 @@ int TPAttrSetIdleTime(ThreadPoolAttr *attr, int idleTime);
*****************************************************************************/ *****************************************************************************/
int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread); int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
/**************************************************************************** /****************************************************************************
* Function: TPAttrSetStarvationTime * Function: TPAttrSetStarvationTime
* *
@ -499,6 +558,7 @@ int TPAttrSetJobsPerThread(ThreadPoolAttr *attr, int jobsPerThread);
*****************************************************************************/ *****************************************************************************/
int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime); int TPAttrSetStarvationTime(ThreadPoolAttr *attr, int starvationTime);
/**************************************************************************** /****************************************************************************
* Function: TPAttrSetSchedPolicy * Function: TPAttrSetSchedPolicy
* *
@ -526,6 +586,7 @@ int TPAttrSetSchedPolicy(ThreadPoolAttr *attr, PolicyType schedPolicy);
*****************************************************************************/ *****************************************************************************/
int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal); int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
/**************************************************************************** /****************************************************************************
* Function: ThreadPoolGetStats * Function: ThreadPoolGetStats
* *
@ -540,18 +601,20 @@ int TPAttrSetMaxJobsTotal(ThreadPoolAttr *attr, int maxJobsTotal);
* Always returns 0. * Always returns 0.
*****************************************************************************/ *****************************************************************************/
#ifdef STATS #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 #else
static UPNP_INLINE int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats) {} static UPNP_INLINE int ThreadPoolGetStats(ThreadPool *tp, ThreadPoolStats *stats) {}
static UPNP_INLINE void ThreadPoolPrintStats(ThreadPoolStats *stats) {} static UPNP_INLINE void ThreadPoolPrintStats(ThreadPoolStats *stats) {}
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* ThreadPool */
#endif /* THREADPOOL_H */

View File

@ -29,160 +29,139 @@
* *
******************************************************************************/ ******************************************************************************/
#ifndef TIMERTHREAD_H #ifndef TIMERTHREAD_H
#define TIMERTHREAD_H #define TIMERTHREAD_H
/*!
* \file
*/
#include "FreeList.h"
#include "ithread.h" #include "ithread.h"
#include "LinkedList.h" #include "LinkedList.h"
#include "FreeList.h"
#include "ThreadPool.h" #include "ThreadPool.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define INVALID_EVENT_ID (-10 & 1<<29) #define INVALID_EVENT_ID (-10 & 1<<29)
/* Timeout Types */ /* Timeout Types */
/* absolute means in seconds from Jan 1, 1970 */ /* absolute means in seconds from Jan 1, 1970 */
/* relative means in seconds from current time */ /* relative means in seconds from current time */
typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType; typedef enum timeoutType {ABS_SEC,REL_SEC} TimeoutType;
/**************************************************************************** /*!
* Name: 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.
* Description: *
* A timer thread similar to the one in the Upnp SDK that allows * Because the timer thread uses the thread pool there is no
* the scheduling of a job to run at a specified time in the future * gurantee of timing, only approximate timing.
* Because the timer thread uses the thread pool there is no *
* gurantee of timing, only approximate timing. * Uses ThreadPool, Mutex, Condition, Thread.
* Uses ThreadPool, Mutex, Condition, Thread */
*
*
*****************************************************************************/
typedef struct TIMERTHREAD typedef struct TIMERTHREAD
{ {
ithread_mutex_t mutex; ithread_mutex_t mutex;
ithread_cond_t condition; ithread_cond_t condition;
int lastEventId; int lastEventId;
LinkedList eventQ; LinkedList eventQ;
int shutdown; int shutdown;
FreeList freeEvents; FreeList freeEvents;
ThreadPool *tp; ThreadPool *tp;
} TimerThread; } TimerThread;
/**************************************************************************** /*!
* Name: TimerEvent * Struct to contain information for a timer event.
* *
* Description: * Internal to the TimerThread.
* */
* Struct to contain information for a timer event.
* Internal to the TimerThread
*
*****************************************************************************/
typedef struct TIMEREVENT typedef struct TIMEREVENT
{ {
ThreadPoolJob job; ThreadPoolJob job;
time_t eventTime; /* absolute time for event in seconds since Jan 1, 1970 */ /*! [in] Absolute time for event in seconds since Jan 1, 1970. */
Duration persistent; /* long term or short term job */ time_t eventTime;
int id; /*! [in] Long term or short term job. */
Duration persistent;
int id;
} TimerEvent; } TimerEvent;
/*!
* \brief Initializes and starts timer thread.
/************************************************************************
* Function: TimerThreadInit
*
* Description:
* Initializes and starts timer thread.
* *
* Parameters: * \return 0 on success, nonzero on failure. Returns error from
* timer - valid timer thread pointer. * ThreadPoolAddPersistent on failure.
* tp - valid thread pool to use. Must be */
* started. Must be valid for lifetime int TimerThreadInit(
* of timer. Timer must be shutdown /*! [in] Valid timer thread pointer. */
* BEFORE thread pool. TimerThread *timer,
* Return: /*! [in] Valid thread pool to use. Must be started. Must be valid for
* 0 on success, nonzero on failure * lifetime of timer. Timer must be shutdown BEFORE thread pool. */
* Returns error from ThreadPoolAddPersistent on failure. ThreadPool *tp);
*
************************************************************************/
int TimerThreadInit(TimerThread *timer,
ThreadPool *tp);
/************************************************************************ /*!
* Function: TimerThreadSchedule * \brief Schedules an event to run at a specified time.
*
* Description:
* Schedules an event to run at a specified time.
* *
* Parameters: * \return 0 on success, nonzero on failure, EOUTOFMEM if not enough memory
* timer - valid timer thread pointer. * to schedule job.
* time_t - time of event. */
* either in absolute seconds, int TimerThreadSchedule(
* or relative seconds in the future. /*! [in] Valid timer thread pointer. */
* timeoutType - either ABS_SEC, or REL_SEC. TimerThread* timer,
* if REL_SEC, then the event /*! [in] time of event. Either in absolute seconds, or relative
* will be scheduled at the * seconds in the future. */
* current time + REL_SEC. time_t time,
* job-> valid Thread pool job with following fields /*! [in] either ABS_SEC, or REL_SEC. If REL_SEC, then the event
* func - function to schedule * will be scheduled at the current time + REL_SEC. */
* arg - argument to function TimeoutType type,
* priority - priority of job. /*! [in] Valid Thread pool job with following fields. */
* ThreadPoolJob *job,
* id - id of timer event. (out, can be null) /*! [in] . */
* Return: Duration duration,
* 0 on success, nonzero on failure /*! [in] Id of timer event. (out, can be null). */
* EOUTOFMEM if not enough memory to schedule job. int *id);
*
************************************************************************/
int TimerThreadSchedule(TimerThread* timer,
time_t time,
TimeoutType type,
ThreadPoolJob *job,
Duration duration,
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 * \brief Removes an event from the timer Q.
* *
* Description: * Events can only be removed before they have been placed in the thread pool.
* Shutdown the timer thread *
* Events scheduled in the future will NOT be run. * \return 0 on success, INVALID_EVENT_ID on failure.
* Timer thread should be shutdown BEFORE it's associated */
* thread pool. int TimerThreadRemove(
* Returns: /*! [in] Valid timer thread pointer. */
* returns 0 if succesfull, TimerThread *timer,
* nonzero otherwise. /*! [in] Id of event to remove. */
* Always returns 0. int id,
***********************************************************************/ /*! [in] Space for thread pool job. */
int TimerThreadShutdown(TimerThread *timer); 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 #ifdef __cplusplus
} }

View File

@ -34,6 +34,11 @@
#define ITHREADH #define ITHREADH
/*!
* \file
*/
#include "UpnpGlobal.h" /* For EXPORT_SPEC */ #include "UpnpGlobal.h" /* For EXPORT_SPEC */

View File

@ -1,68 +1,69 @@
/////////////////////////////////////////////////////////////////////////// /*******************************************************************************
// *
// Copyright (c) 2000-2003 Intel Corporation * Copyright (c) 2000-2003 Intel Corporation
// All rights reserved. * All rights reserved.
// *
// Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
// *
// * Redistributions of source code must retain the above copyright notice, * - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, * - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors * - Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
// without specific prior written permission. * without specific prior written permission.
// *
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// *
/////////////////////////////////////////////////////////////////////////// ******************************************************************************/
/*!
* \file
*/
#include "TimerThread.h" #include "TimerThread.h"
#include <assert.h> #include <assert.h>
/****************************************************************************
* Function: FreeTimerEvent /*!
* * \brief Deallocates a dynamically allocated TimerEvent.
* Description: */
* Deallocates a dynamically allocated TimerEvent. static void FreeTimerEvent(
* Parameters: /*! [in] Valid timer thread pointer. */
* TimerEvent *event - must be allocated with CreateTimerEvent TimerThread *timer,
*****************************************************************************/ /*! [in] Must be allocated with CreateTimerEvent*/
static void TimerEvent *event)
FreeTimerEvent( TimerThread * timer,
TimerEvent * event )
{ {
assert(timer != NULL);
assert( timer != NULL ); FreeListFree(&timer->freeEvents, event);
FreeListFree( &timer->freeEvents, event );
} }
/****************************************************************************
* Function: TimerThreadWorker /*!
* \brief Implements timer thread.
* *
* Description: * Waits for next event to occur and schedules associated job into threadpool.
* Implements timer thread. */
* Waits for next event to occur and schedules static void *TimerThreadWorker(
* associated job into threadpool. /*! [in] arg is cast to (TimerThread *). */
* Internal Only. void *arg)
* Parameters:
* void * arg -> is cast to TimerThread *
*****************************************************************************/
static void *
TimerThreadWorker( void *arg )
{ {
TimerThread *timer = ( TimerThread * ) arg; TimerThread *timer = ( TimerThread * ) arg;
ListNode *head = NULL; ListNode *head = NULL;
@ -81,19 +82,14 @@ TimerThreadWorker( void *arg )
while( 1 ) while( 1 )
{ {
//mutex should always be locked at top of loop //mutex should always be locked at top of loop
//Check for shutdown //Check for shutdown
if( timer->shutdown ) if( timer->shutdown )
{ {
timer->shutdown = 0; timer->shutdown = 0;
ithread_cond_signal( &timer->condition ); ithread_cond_signal( &timer->condition );
ithread_mutex_unlock( &timer->mutex ); ithread_mutex_unlock( &timer->mutex );
return NULL; return NULL;
} }
nextEvent = NULL; nextEvent = NULL;
@ -102,7 +98,6 @@ TimerThreadWorker( void *arg )
if( timer->eventQ.size > 0 ) if( timer->eventQ.size > 0 )
{ {
head = ListHead( &timer->eventQ ); head = ListHead( &timer->eventQ );
nextEvent = ( TimerEvent * ) head->item; nextEvent = ( TimerEvent * ) head->item;
nextEventTime = nextEvent->eventTime; nextEventTime = nextEvent->eventTime;
} }
@ -110,54 +105,42 @@ TimerThreadWorker( void *arg )
currentTime = time( NULL ); currentTime = time( NULL );
//If time has elapsed, schedule job //If time has elapsed, schedule job
if( ( nextEvent != NULL ) && ( currentTime >= nextEventTime ) ) if( ( nextEvent != NULL ) && ( currentTime >= nextEventTime ) )
{ {
if( nextEvent->persistent ) { if( nextEvent->persistent ) {
ThreadPoolAddPersistent( timer->tp, &nextEvent->job, ThreadPoolAddPersistent( timer->tp, &nextEvent->job,
&tempId ); &tempId );
} else { } else {
ThreadPoolAdd( timer->tp, &nextEvent->job, &tempId ); ThreadPoolAdd( timer->tp, &nextEvent->job, &tempId );
} }
ListDelNode( &timer->eventQ, head, 0 ); ListDelNode( &timer->eventQ, head, 0 );
FreeTimerEvent( timer, nextEvent ); FreeTimerEvent( timer, nextEvent );
continue; continue;
} }
if( nextEvent != NULL ) { if( nextEvent != NULL ) {
timeToWait.tv_nsec = 0; timeToWait.tv_nsec = 0;
timeToWait.tv_sec = nextEvent->eventTime; timeToWait.tv_sec = nextEvent->eventTime;
ithread_cond_timedwait( &timer->condition, &timer->mutex, ithread_cond_timedwait( &timer->condition, &timer->mutex,
&timeToWait ); &timeToWait );
} else { } else {
ithread_cond_wait( &timer->condition, &timer->mutex ); ithread_cond_wait( &timer->condition, &timer->mutex );
} }
} }
} }
/****************************************************************************
* Function: CalculateEventTime /*!
* \brief Calculates the appropriate timeout in absolute seconds
* since Jan 1, 1970.
* *
* Description: * \return
* Calculates the appropriate timeout in absolute seconds since */
* Jan 1, 1970 static int CalculateEventTime(
* Internal Only. /*! [in] Timeout. */
* Parameters: time_t *timeout,
* time_t *timeout - timeout /*! [in] Timeout type. */
* TimeoutType type)
*****************************************************************************/
static int
CalculateEventTime( time_t * timeout,
TimeoutType type )
{ {
time_t now; time_t now;
@ -175,29 +158,22 @@ CalculateEventTime( time_t * timeout,
} }
/**************************************************************************** /*!
* Function: CreateTimerEvent * \brief Creates a Timer Event. (Dynamically allocated).
* *
* Description: * \return (TimerEvent *) on success, NULL on failure.
* Creates a Timer Event. (Dynamically allocated) */
* Internal to timer thread. static TimerEvent *CreateTimerEvent(
* Parameters: /*! [in] Valid timer thread pointer. */
* func - thread function to run. TimerThread *timer,
* arg - argument to function. /*! [in] . */
* priority - priority of job. ThreadPoolJob *job,
* eventTime - the absoule time of the event /*! [in] . */
* in seconds from Jan, 1970 Duration persistent,
* id - id of job /*! [in] The absoule time of the event in seconds from Jan, 1970. */
* time_t eventTime,
* Returns: /*! [in] Id of job. */
* TimerEvent * on success, NULL on failure. int id)
****************************************************************************/
static TimerEvent *
CreateTimerEvent( TimerThread * timer,
ThreadPoolJob * job,
Duration persistent,
time_t eventTime,
int id )
{ {
TimerEvent *temp = NULL; TimerEvent *temp = NULL;
@ -215,25 +191,8 @@ CreateTimerEvent( TimerThread * timer,
return temp; return temp;
} }
/************************************************************************
* Function: TimerThreadInit int TimerThreadInit(TimerThread *timer, ThreadPool *tp)
*
* 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 rc = 0; int rc = 0;
@ -290,37 +249,14 @@ TimerThreadInit( TimerThread * timer,
} }
/************************************************************************
* Function: TimerThreadSchedule int TimerThreadSchedule(
* TimerThread *timer,
* Description: time_t timeout,
* Schedules an event to run at a specified time. TimeoutType type,
* ThreadPoolJob *job,
* Parameters: Duration duration,
* timer - valid timer thread pointer. int *id)
* 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 rc = EOUTOFMEM; int rc = EOUTOFMEM;
@ -394,28 +330,11 @@ TimerThreadSchedule( TimerThread * timer,
return rc; return rc;
} }
/************************************************************************
* Function: TimerThreadRemove int TimerThreadRemove(
* TimerThread *timer,
* Description: int id,
* Removes an event from the timer Q. ThreadPoolJob *out)
* 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 rc = INVALID_EVENT_ID; int rc = INVALID_EVENT_ID;
ListNode *tempNode = NULL; ListNode *tempNode = NULL;
@ -450,21 +369,8 @@ TimerThreadRemove( TimerThread * timer,
return rc; return rc;
} }
/************************************************************************
* Function: TimerThreadShutdown int TimerThreadShutdown(TimerThread *timer)
*
* 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 )
{ {
ListNode *tempNode2 = NULL; ListNode *tempNode2 = NULL;
ListNode *tempNode = NULL; ListNode *tempNode = NULL;
@ -517,3 +423,4 @@ TimerThreadShutdown( TimerThread * timer )
return 0; return 0;
} }

View File

@ -81,7 +81,6 @@
*/ */
#define EXPORT_SPEC #define EXPORT_SPEC
/*! /*!
* \brief Declares an inline function. * \brief Declares an inline function.
* *

View File

@ -1,4 +1,4 @@
/************************************************************************** /*******************************************************************************
* *
* Copyright (c) 2000-2003 Intel Corporation * Copyright (c) 2000-2003 Intel Corporation
* All rights reserved. * All rights reserved.
@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
**************************************************************************/ ******************************************************************************/
#include "config.h" #include "config.h"

View File

@ -1,65 +1,59 @@
/////////////////////////////////////////////////////////////////////////// /*******************************************************************************
// *
// Copyright (c) 2000-2003 Intel Corporation * Copyright (c) 2000-2003 Intel Corporation
// All rights reserved. * All rights reserved.
// *
// Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
// *
// * Redistributions of source code must retain the above copyright notice, * * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, * * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors * * Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
// without specific prior written permission. * without specific prior written permission.
// *
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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 "config.h"
#include "upnp_timeout.h" #include "upnp_timeout.h"
#include <stdlib.h>
/************************************************************************ #include <stdlib.h> /* for free() */
* Function : free_upnp_timeout
*
* Parameters : void free_upnp_timeout(upnp_timeout *event)
* 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 )
{ {
if (event) {
if( event ) { if (event->Event) {
if( event->Event ) free(event->Event);
free( event->Event ); }
free( event ); free(event);
}
}
} }

View File

@ -1,58 +1,62 @@
/////////////////////////////////////////////////////////////////////////// /*******************************************************************************
// *
// Copyright (c) 2000-2003 Intel Corporation * Copyright (c) 2000-2003 Intel Corporation
// All rights reserved. * All rights reserved.
// *
// Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
// *
// * Redistributions of source code must retain the above copyright notice, * - Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, * - Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
// * Neither name of Intel Corporation nor the names of its contributors * - Neither name of Intel Corporation nor the names of its contributors
// may be used to endorse or promote products derived from this software * may be used to endorse or promote products derived from this software
// without specific prior written permission. * without specific prior written permission.
// *
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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 { typedef struct UPNP_TIMEOUT {
int EventType; int EventType;
int handle; int handle;
int eventId; int eventId;
void *Event; void *Event;
} upnp_timeout; } upnp_timeout;
/************************************************************************ /*!
* Function : free_upnp_timeout * \brief Free memory associated with event and memory for any sub-elements.
* */
* Parameters : void free_upnp_timeout(
* upnp_timeout *event ; Event which needs to be freed /*! [in] Event which needs to be freed. */
* upnp_timeout *event);
* Description : Free memory associated with event and memory for any
* sub-elements
* #endif /* UPNPTIMEOUT_H */
* Return : void ;
*
* Note :
************************************************************************/
void free_upnp_timeout(upnp_timeout *event);
#endif