예제 #1
0
boolean task_processor_initialize( task_processor* processor )
{
    memory_pool_initialize( &processor->mempool, 512, 4 );
    if ( !hash_map_initialize( &processor->task_queues, sizeof(event_group_element_type), sizeof(task_queue*), &processor->mempool ) )
    {
        memory_pool_destroy( &processor->mempool );
        return FALSE;
    }
    processor->event_group = synchronize_create_event_group();
    if ( NULL == processor->event_group )
    {
        hash_map_destroy( &processor->task_queues );
        memory_pool_destroy( &processor->mempool );
        return FALSE;
    }
    processor->mutex = synchronize_create_mutex();
    if ( NULL == processor->mutex )
    {
        synchronize_destroy_event_group( processor->event_group );
        hash_map_destroy( &processor->task_queues );
        memory_pool_destroy( &processor->mempool );
        return FALSE;
    }
    return TRUE;
}
예제 #2
0
void task_processor_destroy( task_processor* processor )
{
    task_processor_clear_task_queue( processor );

    synchronize_destroy_mutex( processor->mutex );
    synchronize_destroy_event_group( processor->event_group );
    hash_map_destroy( &processor->task_queues );
    memory_pool_destroy( &processor->mempool );
}
예제 #3
0
void synchronize_destroy_event_group( event_group_type _group )
{
    synchronize_event_group* group = _group;
    pthread_cond_destroy( &(group->cond) );
    pthread_mutex_destroy( &(group->mutex) );
    list_destroy( &group->elements );
    object_pool_destroy( &group->objpool );
    memory_pool_destroy( &group->mempool );
    free( group );
}
예제 #4
0
event_group_type synchronize_create_event_group()
{
    synchronize_event_group* group = malloc( sizeof(synchronize_event_group) );
    if ( NULL == group )
    {
        return NULL;
    }
    memset( group, 0, sizeof(synchronize_event_group) );
    memory_pool_initialize( &group->mempool, 1024, 1 );
    if ( !object_pool_initialize( &group->objpool, &group->mempool, sizeof(synchronize_event_group_element) ) )
    {
        memory_pool_destroy( &group->mempool );
        free( group );
        return NULL;
    }
    if ( !list_initialize( &group->elements, sizeof(synchronize_event_group_element*), &group->mempool ) )
    {
        object_pool_destroy( &group->objpool );
        memory_pool_destroy( &group->mempool );
        free( group );
        return NULL;
    }
    if (pthread_mutex_init(&(group->mutex), NULL) != 0)
    {
        list_destroy( &group->elements );
        object_pool_destroy( &group->objpool );
        memory_pool_destroy( &group->mempool );
        free( group );
        return NULL;
    }
    if (pthread_cond_init(&(group->cond), NULL) != 0)
    {
        pthread_mutex_destroy( &(group->mutex) );
        list_destroy( &group->elements );
        object_pool_destroy( &group->objpool );
        memory_pool_destroy( &group->mempool );
        free( group );
        return NULL;
    }

    return group;
}
예제 #5
0
void teardown()
{
  /* Test pools for leaks. */
  fail_unless(memory_pool_n_free(test_pool_seq)
              + memory_pool_n_allocated(test_pool_seq)
              == 50,
              "Memory leak! test_pool_seq lost elements!");

  fail_unless(memory_pool_n_free(test_pool_random)
              + memory_pool_n_allocated(test_pool_random)
              == 20,
              "Memory leak! test_pool_random lost elements!");

  fail_unless(memory_pool_n_free(test_pool_empty)
              + memory_pool_n_allocated(test_pool_empty)
              == 50,
              "Memory leak! test_pool_empty lost elements!");

  memory_pool_destroy(test_pool_seq);
  memory_pool_destroy(test_pool_random);
  memory_pool_destroy(test_pool_empty);
}
예제 #6
0
void rc_destroy(struct radeon_compiler * c)
{
	rc_constants_destroy(&c->Program.Constants);
	memory_pool_destroy(&c->Pool);
	free(c->ErrorMsg);
}