--- cvsroot/Coro/README 2007/01/06 02:45:56 1.6 +++ cvsroot/Coro/README 2007/04/19 10:37:26 1.8 @@ -19,7 +19,7 @@ DESCRIPTION This module collection manages coroutines. Coroutines are similar to threads but don't run in parallel at the same time even on SMP machines. - The specific flavor of coroutine use din this module also guarentees you + The specific flavor of coroutine used in this module also guarantees you that it will not switch between coroutines unless necessary, at easily-identified points in your program, so locking and parallel access are rarely an issue, making coroutine programming much safer than @@ -43,7 +43,7 @@ value is $main (of course). This variable is strictly *read-only*. It is provided for - performance reasons. If performance is not essentiel you are + performance reasons. If performance is not essential you are encouraged to use the "Coro::current" function instead. $idle @@ -68,11 +68,9 @@ (usually unused). When the sub returns the new coroutine is automatically terminated. - Calling "exit" in a coroutine will not work correctly, so do not do - that. - - When the coroutine dies, the program will exit, just as in the main - program. + Calling "exit" in a coroutine will do the same as calling exit + outside the coroutine. Likewise, when the coroutine dies, the + program will exit, just as it would in the main program. # create a new coroutine that just prints its arguments async { @@ -122,7 +120,7 @@ undef $current; }; - # call schedule until event occured. + # call schedule until event occurred. # in case we are woken up for other reasons # (current still defined), loop. Coro::schedule while $current; @@ -157,8 +155,7 @@ returned values were called. To make the coroutine run you must first put it into the ready queue by calling the ready method. - Calling "exit" in a coroutine will not work correctly, so do not do - that. + See "async" for additional discussion. $success = $coroutine->ready Put the given coroutine into the ready queue (according to it's @@ -217,14 +214,14 @@ GLOBAL FUNCTIONS Coro::nready Returns the number of coroutines that are currently in the ready - state, i.e. that can be swicthed to. The value 0 means that the only + state, i.e. that can be switched to. The value 0 means that the only runnable coroutine is the currently running one, so "cede" would have no effect, and "schedule" would cause a deadlock unless there is an idle handler that wakes up some coroutines. my $guard = Coro::guard { ... } This creates and returns a guard object. Nothing happens until the - objetc gets destroyed, in which case the codeblock given as argument + object gets destroyed, in which case the codeblock given as argument will be executed. This is useful to free locks or other resources in case of a runtime error or when the coroutine gets canceled, as in both cases the guard block will be executed. The guard object @@ -248,7 +245,7 @@ original code ref will be called (with parameters) from within its own coroutine. - The reason this fucntion exists is that many event libraries (such + The reason this function exists is that many event libraries (such as the venerable Event module) are not coroutine-safe (a weaker form of thread-safety). This means you must not block within event callbacks, otherwise you might suffer from crashes or worse. @@ -266,7 +263,7 @@ destruction. very bad things might happen otherwise (usually segfaults). - this module is not thread-safe. You should only ever use this module - from the same thread (this requirement might be losened in the future + from the same thread (this requirement might be loosened in the future to allow per-thread schedulers, but Coro::State does not yet allow this).