Disruptor _AbstractSequencer.gatingSequences value Change??

25 views
Skip to first unread message

lg liguo

unread,
Aug 20, 2013, 11:44:39 PM8/20/13
to disrup...@googlegroups.com
hi,
I try to transplant Disruptor(java 3.1.1)to net ,Problems are as follows:
(class file MultiProducerSequencer.java)
 /**
     * @see Sequencer#next(int)
     */
    @Override
    public long next(int n)
    {
        if (n < 1)
        {
            throw new IllegalArgumentException("n must be > 0");
        }

        long current;
        long next;

        do
        {
            current = cursor.get();
            next = current + n;

            long wrapPoint = next - bufferSize;
            long cachedGatingSequence = gatingSequenceCache.get();

            if (wrapPoint > cachedGatingSequence || cachedGatingSequence > current)
            {
                long gatingSequence = Util.getMinimumSequence(gatingSequences, current);
                if(next==32)
                {
                    System.out.println("wrapPoint="+wrapPoint+
                                       ",,gatingSequence="+gatingSequence+
                                       ",,current="+current+
                                       ",,wrapPoint=" + wrapPoint+
                                       ",,cachedGatingSequence=" + cachedGatingSequence);
                }
                if (wrapPoint > gatingSequence)
                {
                    LockSupport.parkNanos(1); // TODO, should we spin based on the wait strategy?
                    continue;
                }

                gatingSequenceCache.set(gatingSequence);
            }
            else if (cursor.compareAndSet(current, next))
            {
                break;
            }
        }
        while (true);

        return next;
    }

Variable gatingSequences value, How do  change it? This problem has troubled me,
Reply all
Reply to author
Forward
0 new messages