Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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.

In reply to Re^3: AnyEvent: How to protect critical sections? by Corion
in thread AnyEvent: How to protect critical sections? by saintmike

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (4)
    As of 2020-07-08 05:00 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found