I was a bit wrong in my explanation. The problem exists not when shating an instance between threads, but when different instances are processed inside the same thread. E.g. in one method you operate on instance A, then somewhere deeper in the stack you operate on instance B. There is a chance, the you will get a future from instance A when calling B.future().
On Mon, Mar 23, 2015 at 3:40 PM, Sergey Evdokimov <[email protected]> wrote: > Result of asynchronous operation will be saved to ThreadLocal, so no > problem with sharing between threads. > > On Mon, Mar 23, 2015 at 1:47 PM, Vladimir Ozerov <[email protected]> > wrote: > > > Hi, > > > > Consider the following scenario: > > > > IgniteCache cache = ignite.cache(); > > > > IgniteCache cache1 = cache.withAsync(); > > IgniteCache cache2 = cache1.withAsync(); > > > > cache1.put(...); > > > > assert cache2.future() != null; > > > > It means that currently no async instance can be shared between threads > > safely. > > > > Shouldn't we create new instance every time "withAsync()" is called? Or > > current semantics was implemented intentionally? > > > > Vladimir. > > >
