Udostępnij za pośrednictwem


StampedLock.TryConvertToOptimisticRead(Int64) Method

Definition

If the lock state matches the given stamp then, atomically, if the stamp represents holding a lock, releases it and returns an observation stamp.

[Android.Runtime.Register("tryConvertToOptimisticRead", "(J)J", "GetTryConvertToOptimisticRead_JHandler", ApiSince=24)]
public virtual long TryConvertToOptimisticRead (long stamp);
[<Android.Runtime.Register("tryConvertToOptimisticRead", "(J)J", "GetTryConvertToOptimisticRead_JHandler", ApiSince=24)>]
abstract member TryConvertToOptimisticRead : int64 -> int64
override this.TryConvertToOptimisticRead : int64 -> int64

Parameters

stamp
Int64

a stamp

Returns

a valid optimistic read stamp, or zero on failure

Attributes

Remarks

If the lock state matches the given stamp then, atomically, if the stamp represents holding a lock, releases it and returns an observation stamp. Or, if an optimistic read, returns it if validated. This method returns zero in all other cases, and so may be useful as a form of "tryUnlock".

Java documentation for java.util.concurrent.locks.StampedLock.tryConvertToOptimisticRead(long).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to