Class TestableCpuWorker
java.lang.Object
br.com.objectos.testing.concurrent.TestableCpuWorker
- All Implemented Interfaces:
CpuWorker
A
CpuWorker implementation that can be inspected for correct task
submission but that does not execute any of the submitted tasks.- Since:
- 2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclear()Removes all tasks in this worker.final booleanAdds the specified task to this worker but does not execute it.final CpuTaskpeek()Retrieves, but does not remove, the head of this worker or returnsnullif this worker is empty.final CpuTaskpoll()Retrieves and removes the head of this worker, or returnsnullif this worker is empty.final intsize()Returns the number of tasks in this worker.final ImmutableList<CpuTask>Returns a new list containing all tasks currently in this worker.
-
Constructor Details
-
TestableCpuWorker
public TestableCpuWorker()Creates a new instance.
-
-
Method Details
-
clear
public final void clear()Removes all tasks in this worker. -
offer
Adds the specified task to this worker but does not execute it. -
peek
Retrieves, but does not remove, the head of this worker or returnsnullif this worker is empty.The head is the task which has been the longest in this worker.
- Returns:
- the head of this worker, or
nullif this worker is empty
-
poll
Retrieves and removes the head of this worker, or returnsnullif this worker is empty.The head is the task which has been the longest in this worker.
- Returns:
- the head of this worker, or
nullif this worker is empty
-
size
public final int size()Returns the number of tasks in this worker.- Returns:
- the number of tasks in this worker
-
toImmutableList
Returns a new list containing all tasks currently in this worker.- Returns:
- a new list containing all tasks currently in this worker
-