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
Line 
1/**
2 * @file queue.c
3 * @author myusgun <myusgun@gmail.com>
4 */
5#include "cf_queue.h"
6#include "cf_debug.h"
7
8#define COUNT 5
9
10int main (void)
11{
12 long long int iter = 0;
13 int result = 0;
14 long long int element = 0;
15 cf_ctx queue = NULL;
16
17 // create
18 result = CF_Queue_Create (&queue);
19 if (result < 0)
20 CF_DEBUG_PRINT (stderr, "error %d\n", result);
21
22 // insert
23 for (iter = 0 ; iter < COUNT ; iter++)
24 {
25 result = CF_Queue_Put (queue, (void *)iter);
26 if (result < 0)
27 CF_DEBUG_PRINT (stderr, "error %d\n", result);
28 }
29
30 // move next
31 for (iter = 0 ; iter < COUNT ; iter++)
32 {
33 result = CF_Queue_Front (queue, (void **)&element);
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
39 result = CF_Queue_Get (queue, (void **)&element);
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
49 result = CF_Queue_Destroy (queue);
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.