The alternative would to internally queue requests. So basically on
every request you would enqueue into an internally maintained list, an
only execute new session requests when there are no outstanding async
tasks.
Regards,
Hiram
FuseSource
Web: http://fusesource.com/
@Test
public void testResumeFromDifferentThread() throws InterruptedException {
DispatchQueue queue = dispatcher.createQueue("test");
final HawtCustomDispatchSource<Integer, Integer> source =
new HawtCustomDispatchSource<Integer, Integer>(dispatcher, EventAggregators.INTEGER_ADD, queue);
RunnableCountDownLatch eventHandler = new RunnableCountDownLatch(1){
@Override
public void run() {
assertEquals(new Integer(9), source.getData());
super.run(); //To change body of overridden methods use File | Settings | File Templates.
}
};
source.setEventHandler(eventHandler);
DispatchQueue globalQueue = dispatcher.getGlobalQueue();
globalQueue.execute(new Task() {
@Override
public void run() {
source.resume();
}
});
globalQueue.execute(new Task() {
@Override
public void run() {
source.merge(4);
source.merge(5);
}
});
assertTrue(eventHandler.await(1, TimeUnit.SECONDS));
}
On Monday, July 25, 2011 7:15:09 AM UTC-7, Hiram Chirino wrote:I think the suspend/resume should work ok as you described.
This tiny detail makes serial queues make sense to me. Thank you!Am I right in believing that I should be able to call .resume() from an unrelated thread without any issues?JAmes