/simpletypesystem/trunk

To get this branch, use:
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) {
121.1.3 by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
28
  s_free (itt);
116.1.3 by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing.
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 ();
121.1.3 by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
36
116.1.3 by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing.
37
  test_case (loop != NULL, "The loop is not NULL");
121.1.3 by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
38
39
  sint * itt = s_malloc (sizeof (sint));
116.1.1 by Gustav Hartvigsson
* Implemented the SMainLoop
40
  *itt = 0;
121.1.3 by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
41
116.1.3 by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing.
42
  s_main_loop_add_teardown_handler (loop, CALLBACK (_do_teardown), itt, NULL);
121.1.3 by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
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);
121.1.3 by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
50
116.1.3 by Gustav Hartvigsson
* Something wring with the STherad... Will have to re-implement the whole thing.
51
  s_print ("Value: %d\n", *itt);
121.1.3 by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
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);
121.1.3 by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set.
56
116.1.1 by Gustav Hartvigsson
* Implemented the SMainLoop
57
  end_unit ();
58
}