void nsToolkit::RunPump(void* arg) { int32 code; char portname[64]; ThreadInterfaceData id; ThreadInitInfo *info = (ThreadInitInfo*)arg; PR_EnterMonitor(info->monitor); gThreadState = PR_TRUE; PR_Notify(info->monitor); PR_ExitMonitor(info->monitor); delete info; // system wide unique names PR_snprintf(portname, sizeof(portname), "event%lx", (long unsigned) PR_GetCurrentThread()); port_id event = create_port(100, portname); while(read_port(event, &code, &id, sizeof(id)) >= 0) { switch(code) { case WM_CALLMETHOD : { MethodInfo *mInfo = (MethodInfo *)id.data; mInfo->Invoke(); if(id.waitingThread != 0) resume_thread(id.waitingThread); delete mInfo; } break; case 'natv' : // native queue PLEvent { PREventQueue *queue = (PREventQueue *)id.data; PR_ProcessPendingEvents(queue); } break; default : printf("nsToolkit::RunPump - UNKNOWN EVENT\n"); break; } } }
void nsToolkit::RunPump(void* arg) { int32 code; char portname[64]; ThreadInterfaceData id; ThreadInitInfo *info = (ThreadInitInfo*)arg; PR_EnterMonitor(info->monitor); gThreadState = PR_TRUE; PR_Notify(info->monitor); PR_ExitMonitor(info->monitor); delete info; // system wide unique names int32 cookie = 0; image_info iinfo; char *leaf = NULL; do { if (get_next_image_info(0, &cookie, &iinfo) == B_OK && strlen(iinfo.name) > 0 && (leaf = strrchr(iinfo.name, '/')) != NULL) { leaf++; PR_snprintf(portname, sizeof(portname), "event%lx", (long unsigned) find_thread(leaf)); } else { PR_snprintf(portname, sizeof(portname), "event%lx", (long unsigned) find_thread(0)); } } while(iinfo.type != B_APP_IMAGE); port_id event = create_port(200, portname); while(read_port(event, &code, &id, sizeof(id)) >= 0) { switch(code) { case WM_CALLMETHOD : { MethodInfo *mInfo = (MethodInfo *)id.data; mInfo->Invoke(); if(id.waitingThread != 0) resume_thread(id.waitingThread); delete mInfo; } break; case 'natv' : // native queue PLEvent { PREventQueue *queue = (PREventQueue *)id.data; PR_ProcessPendingEvents(queue); } break; default : printf("nsToolkit::RunPump - UNKNOWN EVENT\n"); break; } } }