[Net-IMAP-Server] Coro

Alex Vandiver alexmv at bestpractical.com
Tue May 26 13:40:00 EDT 2009


On Tue, 2009-05-26 at 11:30 -0400, Dan Moore wrote:
> Should projects using/subclassing Net::IMAP::Server classes be doing  
> their own 'cede'ing (for instance), or are the command-level cedes  
> already enough?  While I'm certainly familiar with what Coro does, I  
> don't have any experience with it directly nor how best to utilize it  
> within N:I:S.  I'd assume the answer to this would depend highly on  
> exactly what the particular server does, but I thought that there  
> might be some general rules of thumb to follow.

You should 'cede' where it is safe to do so.  The advantage to
co-operative multithreading with 'cede' is that you can choose when to
let some other thread run, based on when you are outside of critical
sections, and when your internal state is guaranteed to be consistent.
  For the most part, though, I've not needed to explicitly 'cede' in
places other than where Net::IMAP::Server implicitly does so.  If you
find that a particular section of code is taking too long to run, it may
be worth investigating if there are appropriate places to 'cede' and
break it up.
 - Alex



More information about the Net-IMAP-Server mailing list