Example #1
0
static void _ensure_pool_return_gracefully_handles_address_not_in_pool( void )
{
	unsigned item_not_in_pool;
	pool_t pool;
	pool_init( &pool, 4, 1, allocator_default( ) );
	pool_return( &pool, &item_not_in_pool );
	TEST_REQUIRE( pool_take( &pool ) != &item_not_in_pool );
	TEST_REQUIRE( pool_take( &pool ) == 0 );
	pool_cleanup( &pool );
}
Example #2
0
static void _ensure_pool_take_reuses_returned_elements( void )
{
	void * item;
	pool_t pool;
	pool_init( &pool, 4, 1, allocator_default( ) );
	item = pool_take( &pool );
	pool_return( &pool, item );
	TEST_REQUIRE( pool_take( &pool ) == item );
	pool_cleanup( &pool );
}
Example #3
0
static void _ensure_pool_take_returns_null_when_empty( void )
{
	void * item;
	pool_t pool;
	pool_init( &pool, 4, 1, allocator_default( ) );
	pool_take( &pool );
	item = pool_take( &pool );
	TEST_REQUIRE( item == 0 );
	pool_cleanup( &pool );
}
Example #4
0
static void _ensure_pool_take_gracefully_handles_cleaned_up_pool( void )
{
	pool_t pool;
	pool_init( &pool, 4, 16, allocator_default( ) );
	pool_cleanup( &pool );
	TEST_REQUIRE( pool_take( &pool ) == 0 );
}
Example #5
0
static void _ensure_pool_is_empty_returns_zero_on_non_empty_legitimate_pool( void )
{
	pool_t pool;
	pool_init( &pool, 4, 1, allocator_default( ) );
	pool_take( &pool );
	TEST_REQUIRE( pool_is_empty( &pool ) != 0 );
	pool_cleanup( &pool );
}
Example #6
0
static void _ensure_pool_return_gracefully_handles_cleaned_up_pool( void )
{
	void * item;
	pool_t pool;
	pool_init( &pool, 4, 1, allocator_default( ) );
	item = pool_take( &pool );
	pool_cleanup( &pool );
	pool_return( &pool, item );
}
Example #7
0
static void _ensure_pool_take_returns_object_when_not_empty( void )
{
	void * item;
	pool_t pool;
	pool_init( &pool, 4, 16, allocator_default( ) );
	item = pool_take( &pool );
	TEST_REQUIRE( item );
	item = 0;
	pool_cleanup( &pool );
}
Example #8
0
void* thread_runner(void* i)
{
    size_t cid = (size_t)i;
    while(!go);
    while(!finish)
    {
        data_t* pd = pool_take(&pool);
        printf("producer: %ld, consumer: %ld, product id: %ld\n", pd->producer, cid, pd->id);
    }
    return NULL;
}
Example #9
0
static void _ensure_pool_take_gracefully_handles_null_pool( void )
{
	TEST_REQUIRE( pool_take( 0 ) == 0 );
}