register root actor
This commit is contained in:
@@ -50,6 +50,7 @@ static SDL_Mutex *actors_mutex = NULL;
|
||||
static struct { char *key; cell_rt *value; } *actors = NULL;
|
||||
static unsigned char *zip_buffer_global = NULL;
|
||||
static char *prosperon = NULL;
|
||||
cell_rt *root_cell = NULL;
|
||||
|
||||
/* Event watch subscribers */
|
||||
char **event_watchers = NULL;
|
||||
@@ -60,6 +61,23 @@ static Uint32 queue_event;
|
||||
static SDL_AtomicInt engine_shutdown;
|
||||
static SDL_Thread **runners = NULL;
|
||||
|
||||
static void exit_handler(void)
|
||||
{
|
||||
SDL_SetAtomicInt(&engine_shutdown, 1);
|
||||
|
||||
/* Push a terminating event to the SDL event queue */
|
||||
SDL_Event terminating_event;
|
||||
terminating_event.type = SDL_EVENT_TERMINATING;
|
||||
SDL_PushEvent(&terminating_event);
|
||||
|
||||
int status;
|
||||
SDL_BroadcastCondition(queue_cond);
|
||||
for (int i = 0; i < arrlen(runners); i++)
|
||||
SDL_WaitThread(runners[i], &status);
|
||||
|
||||
SDL_Quit();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void actor_free(cell_rt *actor)
|
||||
{
|
||||
@@ -134,8 +152,9 @@ void actor_free(cell_rt *actor)
|
||||
|
||||
free(actor);
|
||||
|
||||
if (remaining == 0)
|
||||
if (actor == root_cell)
|
||||
exit(0);
|
||||
// exit_handler();
|
||||
}
|
||||
|
||||
static Uint32 actor_remove_cb(cell_rt *actor, Uint32 id, Uint32 interval)
|
||||
@@ -806,24 +825,6 @@ static int crank_actor(void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void exit_handler(void)
|
||||
{
|
||||
SDL_SetAtomicInt(&engine_shutdown, 1);
|
||||
|
||||
/* Push a terminating event to the SDL event queue */
|
||||
SDL_Event terminating_event;
|
||||
terminating_event.type = SDL_EVENT_TERMINATING;
|
||||
SDL_PushEvent(&terminating_event);
|
||||
|
||||
int status;
|
||||
SDL_BroadcastCondition(queue_cond);
|
||||
for (int i = 0; i < arrlen(runners); i++)
|
||||
SDL_WaitThread(runners[i], &status);
|
||||
|
||||
SDL_Quit();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void signal_handler(int sig)
|
||||
{
|
||||
const char *str = NULL;
|
||||
@@ -1579,7 +1580,7 @@ int main(int argc, char **argv)
|
||||
wota_write_array(&startwota, actor_argc-1);
|
||||
for (int i = 1; i < actor_argc; i++)
|
||||
wota_write_text(&startwota, actor_argv[i]);
|
||||
create_actor(startwota.data,NULL); // this can fall off because the actor takes care of freeing the wota data
|
||||
root_cell = create_actor(startwota.data,NULL); // this can fall off because the actor takes care of freeing the wota data
|
||||
|
||||
/* Start the thread that pumps ready actors, one per logical core. */
|
||||
for (int i = 0; i < cores; i++) {
|
||||
|
||||
@@ -75,6 +75,8 @@ typedef struct cell_rt {
|
||||
extern SDL_ThreadID main_thread;
|
||||
extern SDL_TLSID prosperon_id;
|
||||
|
||||
extern cell_rt *root_cell; // first actor in the system
|
||||
|
||||
cell_rt *create_actor(void *wota, void (*hook)(JSContext*));
|
||||
const char *register_actor(const char *id, cell_rt *actor, int mainthread);
|
||||
void actor_disrupt(cell_rt *actor);
|
||||
|
||||
Reference in New Issue
Block a user