ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/State.pm
(Generate patch)

Comparing Coro/Coro/State.pm (file contents):
Revision 1.116 by root, Wed Nov 5 15:38:10 2008 UTC vs.
Revision 1.117 by root, Fri Nov 7 20:27:47 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines