Conversation
| public void schedule(Runnable runnable) { | ||
| myManager.getEdt().schedule(runnable); | ||
| public Async<Void> schedule(Runnable runnable) { | ||
| return myManager.getEdt().schedule(runnable); |
There was a problem hiding this comment.
As far as I understand kill() contract, it should fail all asyncs that was scheduled in corresponding edt. As far as I see, this implementation fails to follow such contract.
|
|
||
| long getCurrentTimeMillis(); | ||
| void schedule(Runnable r) throws EdtException; | ||
| Async<Void> schedule(Runnable r) throws EdtException; |
There was a problem hiding this comment.
may be we need to clarify threading of callbacks and kill/finish semantics?
| @Override | ||
| public void run() { | ||
| task.run(); | ||
| myUnresolvedAsyncs.remove(i); |
There was a problem hiding this comment.
can shutdownNow() interrupt this runnable between task.run() and myUnresolvedAsyncs().remove? If so, kill() method can throw exception about failing already completed async
| Async<Void> schedule(Runnable r) throws EdtException; | ||
| <ResultT> Async<ResultT> schedule(Supplier<ResultT> s) throws EdtException; | ||
| <ResultT> Async<ResultT> flatSchedule(Supplier<Async<ResultT>> s) throws EdtException; | ||
| Registration schedule(int delay, Runnable r) throws EdtException; |
There was a problem hiding this comment.
may be schedule(int delay, Runnable r) should return AsyncWithRegistration?
| } | ||
|
|
||
|
|
||
| private Registration schedule(int delay, RunnableWithAsync<?> r) { |
There was a problem hiding this comment.
there are a lot of duplication in two schedule() methods
| public void run() { | ||
| try { | ||
| T resultT = supplier.get(); | ||
| if (fulfilled.compareAndSet(false, true)) { |
There was a problem hiding this comment.
Are there any cases when this compareAndSet will happen?
| return async(s); | ||
| } | ||
|
|
||
| private static <T> Runnable fromPlainSupplier(final Supplier<T> supplier, final ThreadSafeAsync<T> async, |
There was a problem hiding this comment.
There is duplication in fromPlainSupplier and fromAsyncSupplier methods
| scheduleInfiniteAndKill(getDefaultSupplier()); | ||
| } | ||
|
|
||
| private void scheduleInfiniteAndKill(Supplier<?>... restTasks) { |
| void schedule(Runnable r) throws EdtException; | ||
| Async<Void> schedule(Runnable r) throws EdtException; | ||
| <ResultT> Async<ResultT> schedule(Supplier<ResultT> s) throws EdtException; | ||
| <ResultT> Async<ResultT> flatSchedule(Supplier<Async<ResultT>> s) throws EdtException; |
There was a problem hiding this comment.
Can you illustrate how this method will be used?
|
|
||
| final class EdtTestUtil { | ||
| private static final int VALUE = 42; | ||
| static Supplier<Integer> getDefaultSupplier() { |
There was a problem hiding this comment.
there should be a blank line after 42
Make EDT accept suppliers and return asyncs