}, s);
}
public static <T> HystrixFuture<T> from(final Action1<Promise<T>> action, Scheduler s) {
final Promise<T> p = Promise.create();
final Worker worker = s.createWorker();
worker.schedule(new Action0() {
@Override
public void call() {
try {
action.call(p);
} catch (Exception e) {
p.onError(e);
} finally {
worker.unsubscribe();
}
}
});
return HystrixFuture.create(p, new Action0() {
@Override
public void call() {
worker.unsubscribe();
}
});
}