Split initialisation into own function

this unbreaks the samples
This commit is contained in:
Moritz Bitsch 2020-10-16 16:22:00 +02:00
parent 9048c9700b
commit 31f2d9c602
4 changed files with 15 additions and 5 deletions

View file

@ -82,11 +82,17 @@ _process_events()
} }
} }
int void
coio_main() coio_init()
{ {
/* initialize empty ctx for scheduler */ /* initialize empty ctx for scheduler */
coio_sched_ctx = co_active(); coio_sched_ctx = co_active();
}
int
coio_main()
{
coio_init();
/* scheduler mainloop */ /* scheduler mainloop */
for (;;) { for (;;) {

2
coio.h
View file

@ -25,6 +25,8 @@ typedef unsigned long long uvlong;
extern CoioTask* coio_current; extern CoioTask* coio_current;
void
coio_init();
int int
coio_main(); coio_main();
int int

View file

@ -137,7 +137,7 @@ coio_source_finalize(GSource* source)
GSource* GSource*
coio_gsource_create() coio_gsource_create()
{ {
coio_sched_ctx = co_active(); coio_init();
static GSourceFuncs funcs = { coio_source_prepare, static GSourceFuncs funcs = { coio_source_prepare,
coio_source_check, coio_source_check,

View file

@ -17,7 +17,7 @@
#include "coio.h" #include "coio.h"
void void
_t1(void* arg) _t1()
{ {
printf("going to sleep 1000ms (1s)\n"); printf("going to sleep 1000ms (1s)\n");
coio_delay(1000); coio_delay(1000);
@ -30,7 +30,9 @@ main(int argc, char** argv)
(void) argc; (void) argc;
(void) argv; (void) argv;
coio_create("t1", _t1, NULL, 0x8000); coio_init();
coio_create("t1", _t1, 0x8000);
if (coio_main() < 0) { if (coio_main() < 0) {
printf("Deadlocked\n"); printf("Deadlocked\n");