Class ExecutionSequencer.ThreadConfinedTaskQueue
java.lang.Object
com.google.common.util.concurrent.ExecutionSequencer.ThreadConfinedTaskQueue
- Enclosing class:
ExecutionSequencer
This object is unsafely published, but avoids problematic races by relying exclusively on the
identity equality of its Thread field so that the task field is only accessed by a single
thread.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
thread
This field is only used for identity comparisons with the current thread. Field assignments are atomic, but do not provide happens-before ordering; however:- If this field's value == currentThread, we know that it's up to date, because write operations in a thread always happen-before subsequent read operations in the same thread
- If this field's value == null because of unsafe publication, we know that it isn't the object associated with our thread, because if it was the publication wouldn't have been unsafe and we'd have seen our thread as the value. This state is also why a new ThreadConfinedTaskQueue object must be created for each inline execution, because observing a null thread does not mean the object is safe to reuse.
- If this field's value is some other thread object, we know that it's not our thread.
- If this field's value == null because it originally belonged to another thread and that thread cleared it, we still know that it's not associated with our thread
- If this field's value == null because it was associated with our thread and was cleared, we know that we're not executing inline any more
-
nextTask
Only used by the thread associated with this object -
nextExecutor
Only used by the thread associated with this object
-
-
Constructor Details
-
ThreadConfinedTaskQueue
private ThreadConfinedTaskQueue()
-