… | |
… | |
247 | coroutine saved in C<$next>. |
247 | coroutine saved in C<$next>. |
248 | |
248 | |
249 | The "state" of a subroutine includes the scope, i.e. lexical variables and |
249 | The "state" of a subroutine includes the scope, i.e. lexical variables and |
250 | the current execution state (subroutine, stack). |
250 | the current execution state (subroutine, stack). |
251 | |
251 | |
|
|
252 | =item $bytes = $state->rss |
|
|
253 | |
|
|
254 | Returns the memory allocated by the coroutine (which includes static |
|
|
255 | structures, various perl stacks but NOT local variables, arguments or any |
|
|
256 | C context data). This is a rough indication of how much memory it might |
|
|
257 | use. |
|
|
258 | |
252 | =item $state->has_cctx |
259 | =item $state->has_cctx |
253 | |
260 | |
254 | Returns whether the state currently uses a cctx/C coroutine. An active |
261 | Returns whether the state currently uses a cctx/C context. An active |
255 | state always has a cctx, as well as the main program. Other states only |
262 | state always has a cctx, as well as the main program. Other states only |
256 | use a cctxts when needed. |
263 | use a cctxts when needed. |
257 | |
264 | |
258 | =item $bytes = $state->rss |
265 | =item Coro::State::force_cctx |
259 | |
266 | |
260 | Returns the memory allocated by the coroutine (which includes |
267 | Forces the allocation of a C context for the currently running coroutine |
261 | static structures, various perl stacks but NOT local variables, |
268 | (if not already done). Apart from benchmarking there is little point |
262 | arguments or any C stack). |
269 | in doing so, however. |
263 | |
270 | |
264 | =item Coro::State::cctx_count |
271 | =item $ncctx = Coro::State::cctx_count |
265 | |
272 | |
266 | Returns the number of C-level coroutines allocated. If this number is |
273 | Returns the number of C-level coroutines allocated. If this number is |
267 | very high (more than a dozen) it might help to identify points of C-level |
274 | very high (more than a dozen) it might help to identify points of C-level |
268 | recursion in your code and moving this into a separate coroutine. |
275 | recursion in your code and moving this into a separate coroutine. |
269 | |
276 | |
270 | =item Coro::State::cctx_idle |
277 | =item $nidle = Coro::State::cctx_idle |
271 | |
278 | |
272 | Returns the number of allocated but idle (free for reuse) C level |
279 | Returns the number of allocated but idle (free for reuse) C level |
273 | coroutines. Currently, Coro will limit the number of idle/unused cctxs to |
280 | coroutines. Currently, Coro will limit the number of idle/unused cctxs to |
274 | 8. |
281 | 8. |
275 | |
282 | |
276 | =item Coro::State::cctx_stacksize [$new_stacksize] |
283 | =item $old = Coro::State::cctx_stacksize [$new_stacksize] |
277 | |
284 | |
278 | Returns the current C stack size and optionally sets the new I<minimum> |
285 | Returns the current C stack size and optionally sets the new I<minimum> |
279 | stack size to C<$new_stacksize> I<long>s. Existing stacks will not |
286 | stack size to C<$new_stacksize> I<long>s. Existing stacks will not |
280 | be changed, but Coro will try to replace smaller stacks as soon as |
287 | be changed, but Coro will try to replace smaller stacks as soon as |
281 | possible. Any Coro::State that starts to use a stack after this call is |
288 | possible. Any Coro::State that starts to use a stack after this call is |
… | |
… | |
283 | |
290 | |
284 | Please note that Coroutines will only need to use a C-level stack if the |
291 | Please note that Coroutines will only need to use a C-level stack if the |
285 | interpreter recurses or calls a function in a module that calls back into |
292 | interpreter recurses or calls a function in a module that calls back into |
286 | the interpreter, so use of this feature is usually never needed. |
293 | the interpreter, so use of this feature is usually never needed. |
287 | |
294 | |
288 | =item Coro::State::force_cctx |
295 | =item $old = Coro::State::cctx_max_idle [$new_count] |
289 | |
296 | |
290 | Forces the allocation of a C context for the currently running coroutine |
297 | Coro caches C contexts that are not in use currently, as creating them |
291 | (if not already done). Apart from benchmarking there is little point |
298 | from scratch has some overhead. |
292 | in doing so, however. |
299 | |
|
|
300 | This function returns the current maximum number of idle C contexts and |
|
|
301 | optionally sets the new amount. The count must be at least C<1>, with the |
|
|
302 | default being C<4>. |
293 | |
303 | |
294 | =item @states = Coro::State::list |
304 | =item @states = Coro::State::list |
295 | |
305 | |
296 | Returns a list of all states currently allocated. |
306 | Returns a list of all states currently allocated. |
297 | |
307 | |