Constant-size queue?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gabe Moothart

    Constant-size queue?

    Hi,
    I would like to use a System.Collecti ons.Queue which is constant size -
    if it is full, it should fail to add new items instead of growing
    automatically. I looked at the help, and thought that a growth factor of
    1.0 would do this. However, it doesn't seem to have worked. Is there any
    way to keep the queue from growing?

    TIA,
    Gabe
  • Rodger Constandse

    #2
    Re: Constant-size queue?

    Hi,

    There doesn't appear to be a way to do this through the existing interface.

    Since the Enqueue method is virtual, you could create a derived class that
    overrides this method and checks the size before passing the call down to the
    base class.

    -- Rodger

    Time Management Guide - Make better use of your time
    <http://www.TimeThought s.com/timemanagement. htm>

    Gabe Moothart wrote:[color=blue]
    > Hi,
    > I would like to use a System.Collecti ons.Queue which is constant size -
    > if it is full, it should fail to add new items instead of growing
    > automatically. I looked at the help, and thought that a growth factor of
    > 1.0 would do this. However, it doesn't seem to have worked. Is there any
    > way to keep the queue from growing?
    >
    > TIA,
    > Gabe[/color]

    Comment

    • William Stacey [MVP]

      #3
      Re: Constant-size queue?

      These are sometimes called "bounded" queues. I did a bounded-blocking queue
      here:


      Blocking can be really helpful as your thread(s) can just block waiting for
      some input or wait to write output without buzy loops or polling.

      --
      William Stacey [MVP]

      "Gabe Moothart" <gabe@imaginesy stems.net> wrote in message
      news:%23VY8zpTc FHA.2212@TK2MSF TNGP14.phx.gbl. ..[color=blue]
      > Hi,
      > I would like to use a System.Collecti ons.Queue which is constant size - if
      > it is full, it should fail to add new items instead of growing
      > automatically. I looked at the help, and thought that a growth factor of
      > 1.0 would do this. However, it doesn't seem to have worked. Is there any
      > way to keep the queue from growing?
      >
      > TIA,
      > Gabe[/color]


      Comment

      Working...