Package org.jmock.lib.concurrent
Class Synchroniser
java.lang.Object
org.jmock.lib.concurrent.Synchroniser
- All Implemented Interfaces:
ThreadingPolicy
A ThreadingPolicy that makes the Mockery thread-safe and helps tests
synchronise with background threads.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsynchroniseAccessTo
(Invokable mockObject) private Object
synchroniseInvocation
(Invokable mockObject, Invocation invocation) void
Waits for a StatePredicate to become active.void
waitUntil
(StatePredicate p, long timeoutMs) Waits up to a timeout for a StatePredicate to become active.private void
waitUntil
(StatePredicate p, Timeout timeout)
-
Field Details
-
sync
-
firstError
-
invocationDispatcher
-
-
Constructor Details
-
Synchroniser
public Synchroniser() -
Synchroniser
-
-
Method Details
-
waitUntil
Waits for a StatePredicate to become active. Warning: this will wait forever unless the test itself has a timeout.- Parameters:
p
- the StatePredicate to wait for- Throws:
InterruptedException
-
waitUntil
Waits up to a timeout for a StatePredicate to become active. Fails the test if the timeout expires.- Parameters:
p
- the StatePredicate to wait fortimeoutMs
- the timeout in milliseconds- Throws:
InterruptedException
-
waitUntil
- Throws:
InterruptedException
-
synchroniseAccessTo
- Specified by:
synchroniseAccessTo
in interfaceThreadingPolicy
-
synchroniseInvocation
- Throws:
Throwable
-
dispatcher
- Specified by:
dispatcher
in interfaceThreadingPolicy
-