当前位置: 首页>>代码示例>>Java>>正文


Java AtomicReferenceFieldUpdater.getAndSet方法代码示例

本文整理汇总了Java中java.util.concurrent.atomic.AtomicReferenceFieldUpdater.getAndSet方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicReferenceFieldUpdater.getAndSet方法的具体用法?Java AtomicReferenceFieldUpdater.getAndSet怎么用?Java AtomicReferenceFieldUpdater.getAndSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.atomic.AtomicReferenceFieldUpdater的用法示例。


在下文中一共展示了AtomicReferenceFieldUpdater.getAndSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dispose

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; //导入方法依赖的package包/类
/**
 * Atomically dispose the {@link Disposable} in the field if not already disposed.
 *
 * @param updater the target field updater
 * @param holder the target instance holding the field
 * @return true if the {@link Disposable} held by the field was properly disposed
 */
static <T> boolean dispose(AtomicReferenceFieldUpdater<T, Disposable> updater, T holder) {
	Disposable current = updater.get(holder);
	Disposable d = DISPOSED;
	if (current != d) {
		current = updater.getAndSet(holder, d);
		if (current != d) {
			if (current != null) {
				current.dispose();
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:22,代码来源:Disposables.java

示例2: dispose

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; //导入方法依赖的package包/类
/**
 * Atomically dispose the {@link Disposable} in the field if not already disposed.
 *
 * @param updater the target field updater
 * @param holder the target instance holding the field
 * @return true if the {@link Disposable} held by the field was properly disposed
 */
public static <T> boolean dispose(AtomicReferenceFieldUpdater<T, Disposable> updater, T holder) {
	Disposable current = updater.get(holder);
	Disposable d = DISPOSED;
	if (current != d) {
		current = updater.getAndSet(holder, d);
		if (current != d) {
			if (current != null) {
				current.dispose();
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:22,代码来源:OperatorDisposables.java

示例3: terminate

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; //导入方法依赖的package包/类
/**
 * Atomically terminates the subscription if it is not already a
 * {@link #cancelledSubscription()}, cancelling the subscription and setting the field
 * to the singleton {@link #cancelledSubscription()}.
 *
 * @param <F> the instance type containing the field
 * @param field the field accessor
 * @param instance the parent instance
 * @return true if terminated, false if the subscription was already terminated
 */
public static <F> boolean terminate(AtomicReferenceFieldUpdater<F, Subscription> field,
		F instance) {
	Subscription a = field.get(instance);
	if (a != CancelledSubscription.INSTANCE) {
		a = field.getAndSet(instance, CancelledSubscription.INSTANCE);
		if (a != null && a != CancelledSubscription.INSTANCE) {
			a.cancel();
			return true;
		}
	}
	return false;
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:23,代码来源:Operators.java

示例4: terminate

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; //导入方法依赖的package包/类
/**
 * Atomic utility to safely mark a volatile throwable reference with a terminal
 * marker.
 *
 * @param field the atomic container
 * @param instance the reference instance
 * @param <T> the instance type
 *
 * @return the previously masked throwable
 */
@Nullable
public static <T> Throwable terminate(AtomicReferenceFieldUpdater<T, Throwable> field,
		T instance) {
	Throwable current = field.get(instance);
	if (current != TERMINATED) {
		current = field.getAndSet(instance, TERMINATED);
	}
	return current;
}
 
开发者ID:reactor,项目名称:reactor-core,代码行数:20,代码来源:Exceptions.java


注:本文中的java.util.concurrent.atomic.AtomicReferenceFieldUpdater.getAndSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。