public interface ExecHarness extends AutoCloseable
An execution harness is backed by a thread pool.
It is important to call close()
when the object is no longer needed to shutdown this thread pool.
For usage examples, see UnitTest.execHarness()
UnitTest.execHarness()
Modifier and Type | Method and Description |
---|---|
void |
close()
Shuts down the thread pool backing this harness.
|
<T> ExecResult<T> |
execute(Function<Execution,Promise<T>> func)
Synchronously returns a promised value.
|
ExecControl |
getControl()
The execution control for the harness.
|
<T> ExecResult<T> execute(Function<Execution,Promise<T>> func) throws Exception
The given function will execute in a separate thread. The calling thread will block, waiting for the promised value to be provided.
T
- the type of promised valuefunc
- a function that exercises some code that returns a promiseException
- any thrown by the function, or the promise failure exceptionExecControl getControl()
This is typically given to the code under test to perform the async ops.
void close()
close
in interface AutoCloseable