… | |
… | |
39 | use Coro::Multicore; |
39 | use Coro::Multicore; |
40 | |
40 | |
41 | This module has no important API functions to learn or remember. All you |
41 | This module has no important API functions to learn or remember. All you |
42 | need to do is I<load> it before you can take advantage of it. |
42 | need to do is I<load> it before you can take advantage of it. |
43 | |
43 | |
44 | =head1 API FUNCTION |
44 | =head1 API FUNCTIONS |
45 | |
|
|
46 | There is currently a lone API function documented for this module: |
|
|
47 | |
45 | |
48 | =over 4 |
46 | =over 4 |
|
|
47 | |
|
|
48 | =item $previous = Coro::Multicore::enable [$enable] |
|
|
49 | |
|
|
50 | This function enables (if C<$enable> is true) or disables (if C<$enable> |
|
|
51 | is false) the multicore functionality globally. By default, it is enabled. |
|
|
52 | |
|
|
53 | This can be used to effectively disable this module's functionality by |
|
|
54 | default, and enable it only for selected threads or scopes, by calling |
|
|
55 | C<Coro::Multicore::scope_enable>. |
|
|
56 | |
|
|
57 | The function returns the previous value of the enable flag. |
|
|
58 | |
|
|
59 | =item Coro::Multicore::scoped_enable |
|
|
60 | |
|
|
61 | This function instructs Coro::Multicore to handle all requests executed |
|
|
62 | in the current coro thread, from the call to the end of the current scope. |
|
|
63 | |
|
|
64 | Calls to C<scoped_enable> and C<scoped_disable> don't nest very well at |
|
|
65 | the moment, so don't nest them. |
|
|
66 | |
|
|
67 | =item Coro::Multicore::scoped_disable |
|
|
68 | |
|
|
69 | The opposite of C<Coro::Multicore::scope_disable>: instructs Coro::Multicore to |
|
|
70 | I<not> handle the next multicore-enabled request. |
49 | |
71 | |
50 | =item $previous = Coro::Multicore::max_idle_threads [$count] |
72 | =item $previous = Coro::Multicore::max_idle_threads [$count] |
51 | |
73 | |
52 | To run on multiple cores, this module creates I<threads>. Since thread |
74 | To run on multiple cores, this module creates I<threads>. Since thread |
53 | creation is costly, it will keep some of them around for future uses. This |
75 | creation is costly, it will keep some of them around for future uses. This |