當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。