Hello fellow monks,

I'm trying to implement a FIFO non-blocking queue in a project I'm working on. What I want to do is create a queue for a pdf document to be generated. The reason I need the queue is that in the tests I've done if too many people request a pdf to be generated it bogs the server down so much only one or two people get theirs generated. The database its generated from has over a million records and some of the requested pdfs are huge. So I need to put users in line if more than one at a time requests a pdf.

What I have so far is the ability to place a user in queue and check where they are and the average time people have waited in line. The problem I'm having is figuring out how to make it non-blocking if someone decides to abandon their position in line. Currently the way I have it if someone abandons their position it will block everyone else from moving on and getting their job done.

I've never had to implement something like this before so i would appreciate any pointers on how to create something like this. I do realise that I need to have some sort of way of telling if that user who is waiting in line is still there without making the others wait unreasonably long. I was thinking of using a timestamp that updates every time a user checks their position in line.

Thanks for your help,

BMaximus

In reply to How would you implement a FIFO non-blocking queue? by BMaximus

Title:
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, details, 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, summary, 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.