- changed memory allocator functions to own allocator calls

This commit is contained in:
Jan Hutter
2005-11-09 09:11:06 +00:00
parent c1ca1ee042
commit 7953866962
22 changed files with 606 additions and 606 deletions
+16 -16
View File
@@ -1,8 +1,8 @@
/**
* @file scheduler.c
*
*
* @brief implements the scheduler, looks for jobs in event-queue
*
*
*/
/*
@@ -19,28 +19,28 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <stdlib.h>
#include <pthread.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "scheduler.h"
#include "job_queue.h"
#include "globals.h"
/**
* Private data of a scheduler object
*/
typedef struct private_scheduler_s private_scheduler_t;
struct private_scheduler_s {
struct private_scheduler_s {
/**
* Public part of a scheduler object
*/
scheduler_t public;
/**
* Assigned thread to the scheduler_t-object
*/
@@ -50,7 +50,7 @@ struct private_scheduler_s {
/**
* Thread function started at creation of the scheduler object
*
*
* @param this assigned scheduler object
* @return SUCCESS if thread_function ended successfully, FAILED otherwise
*/
@@ -59,7 +59,7 @@ static void scheduler_thread_function(private_scheduler_t * this)
/* cancellation disabled by default */
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
job_t *current_job;
for (;;)
{
/* get a job, this block until one is available */
@@ -75,25 +75,25 @@ static void scheduler_thread_function(private_scheduler_t * this)
static status_t destroy(private_scheduler_t *this)
{
pthread_cancel(this->assigned_thread);
pthread_join(this->assigned_thread, NULL);
pfree(this);
allocator_free(this);
return SUCCESS;
}
scheduler_t * scheduler_create()
{
private_scheduler_t *this = alloc_thing(private_scheduler_t,"private_scheduler_t");
private_scheduler_t *this = allocator_alloc_thing(private_scheduler_t,"private_scheduler_t");
this->public.destroy = (status_t(*)(scheduler_t*)) destroy;
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))scheduler_thread_function, this) != 0)
{
/* thread could not be created */
pfree(this);
allocator_free(this);
return NULL;
}
return &(this->public);
}