Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: AnyEvent: How to protect critical sections?

by BrowserUk (Pope)
on May 17, 2011 at 22:25 UTC ( #905384=note: print w/replies, xml ) Need Help??

in reply to AnyEvent: How to protect critical sections?

Having read and re-read the to and fro between you and Corion, for all the world it sounds like what you really need is real threading.

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

Replies are listed 'Best First'.
Re^2: AnyEvent: How to protect critical sections?
by Anonymous Monk on May 18, 2011 at 19:50 UTC
    He might not want the extra dependency on Coro, and the windows emulation code in perl (the other "threads") is of little help in this case-

      It would seem to me that threads would "perfectly" do what's needed, by having the "timer" thread call sleep and the other thread do the HTTP fetching. Then, the critical HTTP fetch part will need to be protected by a critical section, for example a Thread::Semaphore, or by having the timer queue a request through a Thread::Queue. Depending on the nature of the problem, saintmike might want to avoid queueing more requests while one request (to the same resource) is already in progress.

      Of course, real (OS) threads bring more concurrency problems than Coro brings. I'm not sure which bring be less problems, worrying about only ever calling ->recv in one place and keeping track of what timers to restart, or worrying about locking the proper sections of the code to make them single threaded or globally locked. Both are treatable problems, and neither seems like a clear winner over the other in this scenario.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2020-07-08 11:51 GMT
Find Nodes?
    Voting Booth?

    No recent polls found