Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^6: AnyEvent: How to protect critical sections?

by saintmike (Vicar)
on May 17, 2011 at 21:25 UTC ( [id://905370]=note: print w/replies, xml ) Need Help??


in reply to Re^5: AnyEvent: How to protect critical sections?
in thread AnyEvent: How to protect critical sections?

This cannot work - if you expect ->lock() to block until the semaphore is released, how can it continue to execute the remaining code elsewhere?
The same way that $condvar->recv() blocks and lets code run elsewhere.

Only problem: $condvar->recv() cannot be called from within a callback, according to the AnyEvent docs:

"Note that doing a blocking wait in a callback is not supported by any event loop, that is, recursive invocation of a blocking "->recv" is not allowed,".

  • Comment on Re^6: AnyEvent: How to protect critical sections?

Replies are listed 'Best First'.
Re^7: AnyEvent: How to protect critical sections?
by Anonymous Monk on May 18, 2011 at 19:55 UTC
    Indeed, if you would need to do that, you need to use real threads (e.g. Coro) - the limitation of condvars is partially lifted under Coro.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://905370]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-16 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found