/* Hash iterator function */ static bool svc_start_each(void *svcptr, void *qptr) { struct mog_svc *svc = svcptr; struct mog_queue *q = qptr; struct mog_accept *ac; size_t athr = (size_t)num_processors(NPROC_CURRENT); /* * try to distribute accept() callers between workers more evenly * with wake-one accept() behavior by trimming down on acceptors */ if (worker_processes) { athr /= worker_processes; if (athr == 0) athr = 1; } svc->queue = q; if (svc->mgmt_fd >= 0) { have_mgmt = true; ac = mog_accept_init(svc->mgmt_fd, svc, mog_mgmt_post_accept); /* * mgmt port is rarely used and always persistent, so it * does not need multiple threads for blocking accept() */ mog_thrpool_start(&ac->thrpool, 1, mog_accept_loop, ac); } if (svc->http_fd >= 0) { ac = mog_accept_init(svc->http_fd, svc, mog_http_post_accept); mog_thrpool_start(&ac->thrpool, athr, mog_accept_loop, ac); } if (svc->httpget_fd >= 0) { ac = mog_accept_init(svc->httpget_fd, svc, mog_httpget_post_accept); mog_thrpool_start(&ac->thrpool, athr, mog_accept_loop, ac); } return true; }
unsigned long int octave_num_processors_wrapper (enum octave_nproc_query octave_query) { enum nproc_query query = NPROC_CURRENT; switch (octave_query) { case OCTAVE_NPROC_ALL: query = NPROC_ALL; break; case OCTAVE_NPROC_CURRENT: query = NPROC_CURRENT; break; case OCTAVE_NPROC_CURRENT_OVERRIDABLE: query = NPROC_CURRENT_OVERRIDABLE; break; } return num_processors (query); }