APIdia Launch Partner
Top Description Fields Constructors Methods
sun.nio.fs

pack-priv abstract Class Cancellable

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.util.concurrent.ExecutionException, jdk.internal.misc.InnocuousThread, .Unsafe

Base implementation of a task (typically native) that polls a memory location during execution so that it may be aborted/cancelled before completion. The task is executed by invoking the runInterruptibly method defined here and cancelled by invoking Thread.interrupt.

Field Summary

Modifier and TypeField and Description
private boolean
private Throwable
private final Object
private final long
private static final Unsafe

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected long
addressToPollForCancel()

Returns the memory address of a 4-byte int that should be polled to detect cancellation.

pack-priv final void
cancel()

"cancels" the task by writing bits into memory location that it polled by the task.

protected int
cancelValue()

The value to write to the polled memory location to indicate that the task has been cancelled.

private Throwable
exception()

Returns the exception thrown by the task or null if the task completed successfully.

pack-priv abstract void
implRun()

The task body.

public final void
run()

Implements java.lang.Runnable.run.

Runs this operation.

pack-priv static void
runInterruptibly(Cancellable task)

Invokes the given task in its own thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

completedback to summary
private boolean completed
exceptionback to summary
private Throwable exception
lockback to summary
private final Object lock
pollingAddressback to summary
private final long pollingAddress
unsafeback to summary
private static final Unsafe unsafe

Constructor Detail

Cancellableback to summary
protected Cancellable()

Method Detail

addressToPollForCancelback to summary
protected long addressToPollForCancel()

Returns the memory address of a 4-byte int that should be polled to detect cancellation.

cancelback to summary
pack-priv final void cancel()

"cancels" the task by writing bits into memory location that it polled by the task.

cancelValueback to summary
protected int cancelValue()

The value to write to the polled memory location to indicate that the task has been cancelled. If this method is not overridden then it defaults to MAX_VALUE.

exceptionback to summary
private Throwable exception()

Returns the exception thrown by the task or null if the task completed successfully.

implRunback to summary
pack-priv abstract void implRun() throws Throwable

The task body. This should periodically poll the memory location to check for cancellation.

runback to summary
public final void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
runInterruptiblyback to summary
pack-priv static void runInterruptibly(Cancellable task) throws ExecutionException

Invokes the given task in its own thread. If this (meaning the current) thread is interrupted then an attempt is make to cancel the background thread by writing into the memory location that it polls cooperatively.