Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How to properly shutdown disruptor?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Martin Thompson  
View profile  
 More options Jul 19 2011, 3:05 am
From: Martin Thompson <mjpt...@gmail.com>
Date: Tue, 19 Jul 2011 00:05:58 -0700 (PDT)
Local: Tues, Jul 19 2011 3:05 am
Subject: Re: How to properly shutdown disruptor?
I've tried to keep the API similar to other threading frameworks.  You
are right about the steps above.  I like the idea that halt() just
stops the consumer once it has finished the current cycle in a very
similar way to Thread.interrupt() works.  I often have a method that
checks if a backlog of items is still being processed then call halt.
Remember that if you interrupt a thread you still have to wait on it
finishing by calling join() or similar.

1.
<stop producing>

2.
while (hasBackLog())  // see below
{
    // busy spin

}

3.
for (Consumer consumer: consumers)
{
    consumer.halt();

}

<can restart threads at this point if we want>

4.
executor.shutdown():

/**
 * Check if any consumers have work to do before they catch up with
the producers.
 */
public boolean hasBacklog()
{
    final long cursor = ringBuffer.getCursor();

    for (Consumer consumer : consumers)
    {
        if (cursor != consumer.getSequence())
        {
             return true;
        }
    }

    return false;

}

On Jul 18, 11:59 pm, Olivier Deheurles <m...@odeheurles.com> wrote:
> Hi Curtis,

> Calling halt on a consumer will finish processing current entry (or current entries if you're in the middle of a batch). This call is asynchronous (ie. the call can return before the consumer is properly stoped).

> If you want to stop the consumer(s) when all pending entries have been processed:
> 1) stop publishing ;)
> 2) check consumers have processed the latest sequence number
> 3) Halt consumers when they have reached this sequence number

> If you use Adrian's DisruptorWizard DSL you will see there is a halt method on the DisruptorWizard (but this does not guarantee all pending entries have been processed).

> @LMAX guys: should the halt method on the wizard and on the batch consumer take the sequence number after which you release the consumer thread?

> Olivier

> Le 18 juil. 2011 à 22:34, Curtis Stanford <cur...@stanfordcomputing.com> a écrit :

> > Hi, just wondering what's the proper way to shutdown a disruptor ring and the executor service behind it? I tried calling executor.shutdown but it times out. Calling halt on the consumers doesn't finish what's currently in the ring. My application won't exit with the executor service running. Is there some way to finish what's in the ring but shutdown the threads, etc. afterwards?

> > Thanks

> > Curtis


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.