Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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

by Anonymous Monk
on May 18, 2011 at 19:50 UTC ( #905551=note: print w/replies, xml ) Need Help??

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

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-
  • Comment on Re^2: AnyEvent: How to protect critical sections?

Replies are listed 'Best First'.
Re^3: AnyEvent: How to protect critical sections?
by Corion (Pope) on May 18, 2011 at 20:11 UTC

    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://905551]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2020-07-06 12:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found