5 Replies Latest reply on Feb 1, 2006 11:51 AM by Alex Fu

    Queue message count

    Tim Fox Master

      I noticed, the way message count has been implemented on the core queue is by using state.undelivered().size().

      This is a *very* expensive operation and will basically lock that queue completely for the duration.

      A much better way to do this is to expose SingleLinkedDeque.size() which returns the current size without any synchronization effort. I went to some efforts to ensure that a size of the deque could be maintained without any thread contention between threads adding to the deque and threads removing from the deque.

      This method needs to be exposed up through the State interface and used.

      (Actually the undelivered() method should be removed altogether - it's ugly and heavyweight and we should provide an iterator over the state which uses the deque iterator (which again doesn't cause lock contention) combined with an iterator over the deliveries - this is on my list and should be converted to a JIRA task for beta, but the message count implementation could be fixed easily ASAP)