Aleksey, once again, listener will be called directly in GridFutureAdapter.listen() method if future already completed.
1. execute prepareAsync() 2. prepare phase answer got 3. listener binded (actually not binded but called) @Override public void listen(IgniteInClosure<? super IgniteInternalFuture<R>> lsnr0) { assert lsnr0 != null; boolean done = isDone(); if (!done) { synchronized (this) { done = isDone(); // Double check. if (!done) { if (lsnr == null) lsnr = lsnr0; else if (lsnr instanceof ArrayListener) ((ArrayListener)lsnr).add(lsnr0); else lsnr = (IgniteInClosure)new ArrayListener<IgniteInternalFuture>(lsnr, lsnr0); return; } } } assert done; notifyListener(lsnr0); // HERE: notify listener if future is completed. } On Thu, Mar 2, 2017 at 5:25 PM, voipp <alkuznetsov...@gmail.com> wrote: > Hi all ! During pessimistic transaction we execute prepare phase at > org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal#commitAsync > after executing prepareAsync(); > We bind listener on prepare future. > Perhaps its better initially bind listener and then execute fut.prepare(); ? > > No, what im talking about is at first place prepareAsync() is got executed, > then listener got binded. > Imagine the following flow : > 1. execute prepareAsync(); > 2. prepare phase answer got > 3. listener binded > So, listener would not be called. > > > > -- > View this message in context: > http://apache-ignite-developers.2346864.n4.nabble.com/code-refactoring-suggestion-tp15045p15073.html > Sent from the Apache Ignite Developers mailing list archive at Nabble.com.