/** * waits until the operation is finished and return it's result on success, or throws an error on failure. * * @throws Error or {@link Failure} if operation fails */ public <T> T waitSuccess() throws Error, InterruptedException { join(); if (isSuccess()) return (T) result; if (result instanceof Exception) throw new Error((Exception) result); throw new Failure(result); }