diff options
Diffstat (limited to '')
-rw-r--r-- | src/tests/itoheap.cpp | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/src/tests/itoheap.cpp b/src/tests/itoheap.cpp deleted file mode 100644 index ec06b90..0000000 --- a/src/tests/itoheap.cpp +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include <stdio.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <unistd.h> | ||
11 | |||
12 | #include "bu/itoheap.h" | ||
13 | #include "bu/ito.h" | ||
14 | |||
15 | class Consumer : public Bu::Ito | ||
16 | { | ||
17 | public: | ||
18 | Consumer() | ||
19 | { | ||
20 | } | ||
21 | |||
22 | virtual ~Consumer() | ||
23 | { | ||
24 | } | ||
25 | |||
26 | void run() | ||
27 | { | ||
28 | for( int j = 0; j < 10; j++ ) | ||
29 | { | ||
30 | printf("Trying to read [%d].\n", j ); | ||
31 | |||
32 | try | ||
33 | { | ||
34 | int iNum = hInt.dequeue( 0, 500000 ); | ||
35 | printf("Read %d\n", iNum ); | ||
36 | } | ||
37 | catch( Bu::HeapException &e ) | ||
38 | { | ||
39 | printf("Nothing yet...\n"); | ||
40 | } | ||
41 | } | ||
42 | } | ||
43 | |||
44 | Bu::ItoHeap<int> hInt; | ||
45 | }; | ||
46 | |||
47 | |||
48 | int main() | ||
49 | { | ||
50 | Consumer c; | ||
51 | |||
52 | for( int j = 0; j < 3; j++ ) | ||
53 | { | ||
54 | int iNum = rand()%10; | ||
55 | printf("Enqueuing %d.\n", iNum ); | ||
56 | c.hInt.enqueue( iNum ); | ||
57 | } | ||
58 | |||
59 | printf("Sarting consumer.\n"); | ||
60 | c.start(); | ||
61 | |||
62 | for( int j = 0; j < 5; j++ ) | ||
63 | { | ||
64 | sleep( 1 ); | ||
65 | int iNum = rand()%10; | ||
66 | printf("Enqueuing %d.\n", iNum ); | ||
67 | c.hInt.enqueue( iNum ); | ||
68 | } | ||
69 | } | ||
70 | |||