Renamed GatheringCallback to CountingCallback.
This commit is contained in:
parent
7dffe4f082
commit
44d262c65a
|
@ -49,7 +49,7 @@ import org.eclipse.jetty.io.ByteBufferPool;
|
|||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.Atomics;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.util.GatheringCallback;
|
||||
import org.eclipse.jetty.util.CountingCallback;
|
||||
import org.eclipse.jetty.util.Promise;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -556,7 +556,7 @@ public abstract class HTTP2Session implements ISession, Parser.Listener
|
|||
}
|
||||
else
|
||||
{
|
||||
callback = new GatheringCallback(callback, 1 + length);
|
||||
callback = new CountingCallback(callback, 1 + length);
|
||||
frame(new ControlEntry(frame, stream, callback), false);
|
||||
for (int i = 1; i <= length; ++i)
|
||||
frame(new ControlEntry(frames[i - 1], stream, callback), i == length);
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class GatheringCallback implements Callback
|
||||
{
|
||||
private final Callback callback;
|
||||
private final AtomicInteger count;
|
||||
|
||||
public GatheringCallback(Callback callback, int count)
|
||||
{
|
||||
this.callback = callback;
|
||||
this.count = new AtomicInteger(count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
{
|
||||
// Forward success on the last success.
|
||||
while (true)
|
||||
{
|
||||
int current = count.get();
|
||||
|
||||
// Already completed ?
|
||||
if (current == 0)
|
||||
return;
|
||||
|
||||
if (count.compareAndSet(current, current - 1))
|
||||
{
|
||||
if (current == 1)
|
||||
{
|
||||
callback.succeeded();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable failure)
|
||||
{
|
||||
// Forward failure on the first failure.
|
||||
while (true)
|
||||
{
|
||||
int current = count.get();
|
||||
|
||||
// Already completed ?
|
||||
if (current == 0)
|
||||
return;
|
||||
|
||||
if (count.compareAndSet(current, 0))
|
||||
{
|
||||
callback.failed(failure);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue