source: libcf/trunk/test/queue.c@ 151

Last change on this file since 151 was 151, checked in by cheese, 11 years ago

#1 fix interface and add util module

File size: 1.1 KB
RevLine 
[110]1/**
2 * @file queue.c
3 * @author myusgun <myusgun@gmail.com>
4 */
5#include "cf_queue.h"
6#include "cf_debug.h"
7
[151]8#define COUNT 5
9
[110]10int main (void)
11{
12 long long int iter = 0;
13 int result = 0;
[118]14 long long int element = 0;
[151]15 cf_ctx queue = NULL;
[110]16
17 // create
[151]18 result = CF_Queue_Create (&queue);
[110]19 if (result < 0)
20 CF_DEBUG_PRINT (stderr, "error %d\n", result);
21
22 // insert
[151]23 for (iter = 0 ; iter < COUNT ; iter++)
[110]24 {
[151]25 result = CF_Queue_Put (queue, (void *)iter);
[110]26 if (result < 0)
27 CF_DEBUG_PRINT (stderr, "error %d\n", result);
28 }
29
30 // move next
[151]31 for (iter = 0 ; iter < COUNT ; iter++)
[110]32 {
[151]33 result = CF_Queue_Front (queue, (void **)&element);
[110]34 if (result < 0)
35 CF_DEBUG_PRINT (stderr, "error %d\n", result);
36 else
37 CF_DEBUG_PRINT (stderr, "front : %4d\n", element);
38
[151]39 result = CF_Queue_Get (queue, (void **)&element);
[110]40 if (result < 0)
41 CF_DEBUG_PRINT (stderr, "error %d\n", result);
42 else
43 CF_DEBUG_PRINT (stderr, "got : %4d\n", element);
44
45 CF_DEBUG_PRINT (stderr, "\n");
46 }
47
48 // destroy
[151]49 result = CF_Queue_Destroy (queue);
[110]50 if (result < 0)
51 CF_DEBUG_PRINT (stderr, "error %d\n", result);
52
53 return 0;
54}
Note: See TracBrowser for help on using the repository browser.