本文整理汇总了Java中org.xnio.Cancellable类的典型用法代码示例。如果您正苦于以下问题:Java Cancellable类的具体用法?Java Cancellable怎么用?Java Cancellable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cancellable类属于org.xnio包,在下文中一共展示了Cancellable类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: asyncCancel
import org.xnio.Cancellable; //导入依赖的package包/类
@Override
public void asyncCancel(boolean interruptionDesired) {
final List<Cancellable> cancellables;
synchronized (this) {
cancellables = this.cancellables;
if (cancellables == CANCEL_REQUESTED) {
return;
}
this.cancellables = CANCEL_REQUESTED;
if(cancellables == null) {
setCancelled();
return;
}
}
for (Cancellable cancellable : cancellables) {
cancellable.cancel();
}
setCancelled();
}
示例2: addCancellable
import org.xnio.Cancellable; //导入依赖的package包/类
@Override
public void addCancellable(final Cancellable cancellable) {
// Perhaps just use the IOFuture from XNIO...
synchronized (this) {
switch (getStatus()) {
case CANCELLED:
break;
case WAITING:
final List<Cancellable> cancellables = this.cancellables;
if (cancellables == CANCEL_REQUESTED) {
break;
} else {
((cancellables == null) ? (this.cancellables = new ArrayList<Cancellable>()) : cancellables).add(cancellable);
}
default:
return;
}
}
cancellable.cancel();
}
示例3: cancel
import org.xnio.Cancellable; //导入依赖的package包/类
@Override
public Cancellable cancel() {
if (cancellable && cancelled.compareAndSet(false, true)) {
final Thread thread = this.thread;
if(thread != null) {
thread.interrupt();
ProtocolLogger.ROOT_LOGGER.cancelledAsyncTask(getClass().getSimpleName(), thread);
}
}
return this;
}
示例4: addCancellable
import org.xnio.Cancellable; //导入依赖的package包/类
/**
* Add a cancellation handler.
*
* @param cancellable the cancel handler
*/
void addCancellable(final Cancellable cancellable);