Пример #1
0
/*!
 * \brief Creates a Timer Event. (Dynamically allocated).
 *
 * \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;

    assert( timer != NULL );
    assert( job != NULL );

    temp = ( TimerEvent * ) FreeListAlloc( &timer->freeEvents );
    if( temp == NULL )
        return temp;
    temp->job = ( *job );
    temp->persistent = persistent;
    temp->eventTime = eventTime;
    temp->id = id;

    return temp;
}
Пример #2
0
/****************************************************************************
 * Function: CreateThreadPoolJob
 *
 *  Description:
 *      Creates a Thread Pool Job. (Dynamically allocated)
 *      Internal to thread pool.
 *  Parameters:
 *      ThreadPoolJob *job - job is copied
 *      id - id of job
 *
 *  Returns:
 *      ThreadPoolJob *on success, NULL on failure.
 *****************************************************************************/
static ThreadPoolJob *CreateThreadPoolJob( ThreadPoolJob *job, int id, ThreadPool *tp )
{
	ThreadPoolJob *newJob = NULL;

	assert( job != NULL );
	assert( tp != NULL );

	newJob = (ThreadPoolJob *)FreeListAlloc( &tp->jobFreeList );
	if( newJob ) {
		*newJob = *job;
		newJob->jobId = id;
		gettimeofday( &newJob->requestTime, NULL );
	}

	return newJob;
}
Пример #3
0
/****************************************************************************
 * Function: CreateListNode
 *
 *  Description:
 *      Creates a list node. Dynamically.
 *
 *  Parameters:
 *      void * item - the item to store
 *  Returns:
 *      The new node, NULL on failure.
 *****************************************************************************/
static ListNode *
CreateListNode( void *item,
                LinkedList * list )
{

    ListNode *temp = NULL;

    assert( list != NULL );

    temp = ( ListNode * ) FreeListAlloc( &list->freeNodeList );
    if( temp ) {
        temp->prev = NULL;
        temp->next = NULL;
        temp->item = item;
    }
    return temp;
}
Пример #4
0
/*!
 * \brief Creates a Thread Pool Job. (Dynamically allocated)
 *
 * \internal
 *
 * \return ThreadPoolJob *on success, NULL on failure.
 */
static ThreadPoolJob *CreateThreadPoolJob(
	/*! job is copied. */
	ThreadPoolJob *job,
	/*! id of job. */
	int id,
	/*! . */
	ThreadPool *tp)
{
	ThreadPoolJob *newJob = NULL;

	newJob = (ThreadPoolJob *)FreeListAlloc(&tp->jobFreeList);
	if (newJob) {
		*newJob = *job;
		newJob->jobId = id;
		gettimeofday(&newJob->requestTime, NULL);
	}

	return newJob;
}
Пример #5
0
/****************************************************************************
 * Function: CreateTimerEvent
 *
 *  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 )
{
    TimerEvent *temp = NULL;

    assert( timer != NULL );
    assert( job != NULL );

    temp = ( TimerEvent * ) FreeListAlloc( &timer->freeEvents );
    if( temp == NULL )
        return temp;
    temp->job = ( *job );
    temp->persistent = persistent;
    temp->eventTime = eventTime;
    temp->id = id;

    return temp;
}