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

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

by Anonymous Monk
on May 18, 2011 at 19:50 UTC ( [id://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 (Patriarch) 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found