… | |
… | |
127 | call terminate or join on it (although you are allowed to), and you |
127 | call terminate or join on it (although you are allowed to), and you |
128 | get a coroutine that might have executed other code already (which |
128 | get a coroutine that might have executed other code already (which |
129 | can be good or bad :). |
129 | can be good or bad :). |
130 | |
130 | |
131 | On the plus side, this function is faster than creating (and |
131 | On the plus side, this function is faster than creating (and |
132 | destroying) a completely new coroutine, so if you need a lot of |
132 | destroying) a completly new coroutine, so if you need a lot of |
133 | generic coroutines in quick successsion, use "async_pool", not |
133 | generic coroutines in quick successsion, use "async_pool", not |
134 | "async". |
134 | "async". |
135 | |
135 | |
136 | The code block is executed in an "eval" context and a warning will |
136 | The code block is executed in an "eval" context and a warning will |
137 | be issued in case of an exception instead of terminating the |
137 | be issued in case of an exception instead of terminating the |
… | |
… | |
142 | |
142 | |
143 | The priority will be reset to 0 after each run, tracing will be |
143 | The priority will be reset to 0 after each run, tracing will be |
144 | disabled, the description will be reset and the default output |
144 | disabled, the description will be reset and the default output |
145 | filehandle gets restored, so you can change all these. Otherwise the |
145 | filehandle gets restored, so you can change all these. Otherwise the |
146 | coroutine will be re-used "as-is": most notably if you change other |
146 | coroutine will be re-used "as-is": most notably if you change other |
147 | per-coroutine global stuff such as $/ you *must needs* to revert |
147 | per-coroutine global stuff such as $/ you *must needs* revert that |
148 | that change, which is most simply done by using local as in: " local |
148 | change, which is most simply done by using local as in: "local $/". |
149 | $/ ". |
|
|
150 | |
149 | |
151 | The pool size is limited to 8 idle coroutines (this can be adjusted |
150 | The idle pool size is limited to 8 idle coroutines (this can be |
152 | by changing $Coro::POOL_SIZE), and there can be as many non-idle |
151 | adjusted by changing $Coro::POOL_SIZE), but there can be as many |
153 | coros as required. |
152 | non-idle coros as required. |
154 | |
153 | |
155 | If you are concerned about pooled coroutines growing a lot because a |
154 | If you are concerned about pooled coroutines growing a lot because a |
156 | single "async_pool" used a lot of stackspace you can e.g. |
155 | single "async_pool" used a lot of stackspace you can e.g. |
157 | "async_pool { terminate }" once per second or so to slowly replenish |
156 | "async_pool { terminate }" once per second or so to slowly replenish |
158 | the pool. In addition to that, when the stacks used by a handler |
157 | the pool. In addition to that, when the stacks used by a handler |