-
Notifications
You must be signed in to change notification settings - Fork 727
Closed
Description
The use case that I'm trying to do is similar as in the sample simple, but host_tool and simple is the same process.
I am trying to have the server that handles the wasm-apps and the one that receives the requests in the same process. For that, I have to synchronize both threads to know that the app manager has been initialized.
I have the following structure:
bool host_init() {
pthread_cond_signal(&init_server_cond);
return true;
}
void* init_app_manager(void *args) {
app_manager_startup(&interface);
wasm_runtime_destroy();
return NULL;
}
void run() {
if (os_thread_create(&tid_app_manager, init_app_manager, NULL, BH_APPLET_PRESERVED_STACK_SIZE) != 0) {
printf("Error creating the app_manager.\n");
}
pthread_mutex_lock(&init_server_mutex);
pthread_cond_wait(&init_server_cond, &init_server_mutex);
pthread_mutex_unlock(&init_server_mutex);
}
However, if the main thread receives a petition before the server thread is in the queue loop we can have a problem.
- Is there an official way to handle this? Do we have a way to check that the server is ready to handle petitions?
- What's the expected behavior of sending commands to aee_host_msg_callback if the thread has not entered the queue loop?
In the latter case, I think it would be nice to condition the return value according to the output of am_dispatch_request.
Thank you very much!
Metadata
Metadata
Assignees
Labels
No labels