bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
1 |
#include "mainloop.h" |
2 |
#include <SimpleTypeSystem.h> |
|
3 |
||
4 |
sboolean
|
|
5 |
_do_some_work_1 (sint * itt) { |
|
6 |
s_print ("Hello from Worker 1! itt:%d\n", *itt); |
|
7 |
*itt += 1; |
|
|
116.1.4
by Gustav Hartvigsson
* Removed stupid, non-sense error from SLinkedList. |
8 |
if (*itt >= 100) { |
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
9 |
return FALSE; |
10 |
} else { |
|
11 |
return TRUE; |
|
12 |
} |
|
13 |
}
|
|
14 |
||
15 |
sboolean
|
|
16 |
_do_some_work_2 (sint * itt) { |
|
17 |
s_print ("Hello from Worker 2! itt:%d\n", *itt); |
|
18 |
*itt += 1; |
|
|
116.1.4
by Gustav Hartvigsson
* Removed stupid, non-sense error from SLinkedList. |
19 |
if (*itt >= 100) { |
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
20 |
return FALSE; |
21 |
} else { |
|
22 |
return TRUE; |
|
23 |
} |
|
24 |
}
|
|
25 |
||
|
116.1.3
by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing. |
26 |
void
|
27 |
_do_teardown (sint * itt, spointer user_data) { |
|
28 |
free (itt); |
|
29 |
}
|
|
30 |
||
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
31 |
int test_main_loop (void) { |
32 |
setup_unit (); |
|
33 |
||
|
116.1.3
by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing. |
34 |
SMainLoop * loop = NULL; |
35 |
loop = s_main_loop_get_default (); |
|
36 |
|
|
37 |
test_case (loop != NULL, "The loop is not NULL"); |
|
38 |
|
|
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
39 |
sint * itt = malloc (sizeof (sint)); |
40 |
*itt = 0; |
|
|
116.1.3
by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing. |
41 |
|
42 |
s_main_loop_add_teardown_handler (loop, CALLBACK (_do_teardown), itt, NULL); |
|
43 |
|
|
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
44 |
s_main_loop_add_worker (loop, S_MAIN_LOOP_RING_ONE, RUNFUNC(_do_some_work_1), itt); |
45 |
||
46 |
||
47 |
s_main_loop_add_worker (loop, S_MAIN_LOOP_RING_TWO, RUNFUNC(_do_some_work_2), itt); |
|
48 |
||
49 |
s_main_loop_run (loop); |
|
|
116.1.3
by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing. |
50 |
|
51 |
s_print ("Value: %d\n", *itt); |
|
52 |
|
|
|
116.1.4
by Gustav Hartvigsson
* Removed stupid, non-sense error from SLinkedList. |
53 |
test_case (*itt >= 100, "The avlue of the itterator is "); |
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
54 |
|
55 |
s_main_loop_quit (loop); |
|
|
116.1.3
by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing. |
56 |
|
|
116.1.1
by Gustav Hartvigsson
* Implemented the SMainLoop |
57 |
end_unit (); |
58 |
}
|