… | |
… | |
35 | * and other provisions required by the GPL. If you do not delete the |
35 | * and other provisions required by the GPL. If you do not delete the |
36 | * provisions above, a recipient may use your version of this file under |
36 | * provisions above, a recipient may use your version of this file under |
37 | * either the BSD or the GPL. |
37 | * either the BSD or the GPL. |
38 | */ |
38 | */ |
39 | |
39 | |
|
|
40 | #if HAVE_SYS_PRCTL_H |
|
|
41 | # include <sys/prctl.h> |
|
|
42 | #endif |
|
|
43 | |
|
|
44 | #ifdef EIO_STACKSIZE |
|
|
45 | # define X_STACKSIZE EIO_STACKSIZE |
|
|
46 | #endif |
|
|
47 | #include "xthread.h" |
|
|
48 | |
40 | #ifndef ETP_API_DECL |
49 | #ifndef ETP_API_DECL |
41 | # define ETP_API_DECL static |
50 | # define ETP_API_DECL static |
42 | #endif |
51 | #endif |
43 | |
52 | |
44 | #ifndef ETP_PRI_MIN |
53 | #ifndef ETP_PRI_MIN |
… | |
… | |
309 | static void ecb_noinline ecb_cold |
318 | static void ecb_noinline ecb_cold |
310 | etp_proc_init (void) |
319 | etp_proc_init (void) |
311 | { |
320 | { |
312 | #if HAVE_PRCTL_SET_NAME |
321 | #if HAVE_PRCTL_SET_NAME |
313 | /* provide a more sensible "thread name" */ |
322 | /* provide a more sensible "thread name" */ |
314 | char name[16 + 1]; |
323 | char name[15 + 1]; |
315 | const int namelen = sizeof (name) - 1; |
324 | const int namelen = sizeof (name) - 1; |
316 | int len; |
325 | int len; |
317 | |
326 | |
318 | prctl (PR_GET_NAME, (unsigned long)name, 0, 0, 0); |
327 | prctl (PR_GET_NAME, (unsigned long)name, 0, 0, 0); |
319 | name [namelen] = 0; |
328 | name [namelen] = 0; |
… | |
… | |
586 | etp_maybe_start_thread (pool); |
595 | etp_maybe_start_thread (pool); |
587 | } |
596 | } |
588 | } |
597 | } |
589 | |
598 | |
590 | ETP_API_DECL void ecb_cold |
599 | ETP_API_DECL void ecb_cold |
591 | etp_set_max_poll_time (etp_pool pool, double nseconds) |
600 | etp_set_max_poll_time (etp_pool pool, double seconds) |
592 | { |
601 | { |
593 | if (WORDACCESS_UNSAFE) X_LOCK (pool->reslock); |
602 | if (WORDACCESS_UNSAFE) X_LOCK (pool->reslock); |
594 | pool->max_poll_time = nseconds * ETP_TICKS; |
603 | pool->max_poll_time = seconds * ETP_TICKS; |
595 | if (WORDACCESS_UNSAFE) X_UNLOCK (pool->reslock); |
604 | if (WORDACCESS_UNSAFE) X_UNLOCK (pool->reslock); |
596 | } |
605 | } |
597 | |
606 | |
598 | ETP_API_DECL void ecb_cold |
607 | ETP_API_DECL void ecb_cold |
599 | etp_set_max_poll_reqs (etp_pool pool, unsigned int maxreqs) |
608 | etp_set_max_poll_reqs (etp_pool pool, unsigned int maxreqs) |
… | |
… | |
602 | pool->max_poll_reqs = maxreqs; |
611 | pool->max_poll_reqs = maxreqs; |
603 | if (WORDACCESS_UNSAFE) X_UNLOCK (pool->reslock); |
612 | if (WORDACCESS_UNSAFE) X_UNLOCK (pool->reslock); |
604 | } |
613 | } |
605 | |
614 | |
606 | ETP_API_DECL void ecb_cold |
615 | ETP_API_DECL void ecb_cold |
607 | etp_set_max_idle (etp_pool pool, unsigned int nthreads) |
616 | etp_set_max_idle (etp_pool pool, unsigned int threads) |
608 | { |
617 | { |
609 | if (WORDACCESS_UNSAFE) X_LOCK (pool->reqlock); |
618 | if (WORDACCESS_UNSAFE) X_LOCK (pool->reqlock); |
610 | pool->max_idle = nthreads; |
619 | pool->max_idle = threads; |
611 | if (WORDACCESS_UNSAFE) X_UNLOCK (pool->reqlock); |
620 | if (WORDACCESS_UNSAFE) X_UNLOCK (pool->reqlock); |
612 | } |
621 | } |
613 | |
622 | |
614 | ETP_API_DECL void ecb_cold |
623 | ETP_API_DECL void ecb_cold |
615 | etp_set_idle_timeout (etp_pool pool, unsigned int seconds) |
624 | etp_set_idle_timeout (etp_pool pool, unsigned int seconds) |
… | |
… | |
618 | pool->idle_timeout = seconds; |
627 | pool->idle_timeout = seconds; |
619 | if (WORDACCESS_UNSAFE) X_UNLOCK (pool->reqlock); |
628 | if (WORDACCESS_UNSAFE) X_UNLOCK (pool->reqlock); |
620 | } |
629 | } |
621 | |
630 | |
622 | ETP_API_DECL void ecb_cold |
631 | ETP_API_DECL void ecb_cold |
623 | etp_set_min_parallel (etp_pool pool, unsigned int nthreads) |
632 | etp_set_min_parallel (etp_pool pool, unsigned int threads) |
624 | { |
633 | { |
625 | if (pool->wanted < nthreads) |
634 | if (pool->wanted < threads) |
626 | pool->wanted = nthreads; |
635 | pool->wanted = threads; |
627 | } |
636 | } |
628 | |
637 | |
629 | ETP_API_DECL void ecb_cold |
638 | ETP_API_DECL void ecb_cold |
630 | etp_set_max_parallel (etp_pool pool, unsigned int nthreads) |
639 | etp_set_max_parallel (etp_pool pool, unsigned int threads) |
631 | { |
640 | { |
632 | if (pool->wanted > nthreads) |
641 | if (pool->wanted > threads) |
633 | pool->wanted = nthreads; |
642 | pool->wanted = threads; |
634 | |
643 | |
635 | while (pool->started > pool->wanted) |
644 | while (pool->started > pool->wanted) |
636 | etp_end_thread (pool); |
645 | etp_end_thread (pool); |
637 | } |
646 | } |
638 | |
647 | |