static protected void assertNotOnDispatchQueue() { assert Dispatch.getCurrentQueue()==null : "Not allowed to be called when executing on a dispatch queue"; }
@Override protected ResponseFuture createResponse(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args) throws Exception { return new AsyncResponseFuture(loader, method, serializationStrategy, Dispatch.getCurrentQueue()); }
@Override protected ResponseFuture createResponse(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args) throws Exception { return new AsyncResponseFuture(loader, method, (AsyncCallback) args[args.length-1], serializationStrategy, Dispatch.getCurrentQueue()); }
@Override protected ResponseFuture createResponse(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args) throws Exception { return new AsyncResponseFuture(loader, method, serializationStrategy, Dispatch.getCurrentQueue()); }
protected void fireWatches() { if( !this.watches.isEmpty() ) { Dispatch.getCurrentQueue().execute(new Task(){ @Override public void run() { // Lets see if any of the watches are triggered. LinkedList<Watch> tmp = watches; watches = new LinkedList<Watch>(); for (Watch task : tmp) { if( !task.execute() ) { watches.add(task); } } } }); } }
public ResponseFuture request(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args, DataByteArrayOutputStream target) throws Exception { assert Dispatch.getCurrentQueue() == null : "You should not do blocking RPC class when executing on a dispatch queue"; serializationStrategy.encodeRequest(loader, method.getParameterTypes(), args, target); return new BlockingResponseFuture(loader, method, serializationStrategy); }
public ResponseFuture request(SerializationStrategy serializationStrategy, ClassLoader loader, Method method, Object[] args, DataByteArrayOutputStream target) throws Exception { if(!isAsyncMethod(method)) { throw new IllegalArgumentException("Invalid async method declaration: last argument is not a RequestCallback"); } Class[] new_types = payloadTypes(method); Object[] new_args = new Object[args.length-1]; System.arraycopy(args, 0, new_args, 0, new_args.length); serializationStrategy.encodeRequest(loader, new_types, new_args, target); return new AsyncResponseFuture(loader, method, (AsyncCallback) args[args.length-1], serializationStrategy, Dispatch.getCurrentQueue()); }
public void execute(Runnable task) { if (getCurrentQueue() == null) { queue.execute(new TaskWrapper(task)); } else { source.merge(task); } }
public boolean offer(Object command) { assert Dispatch.getCurrentQueue() == dispatchQueue; try { if (!socketState.is(CONNECTED.class)) { throw new IOException("Not connected."); } if (getServiceState() != STARTED) { throw new IOException("Not running."); } ProtocolCodec.BufferState rc = codec.write(command); switch (rc ) { case FULL: return false; default: if( drained ) { drained = false; resumeWrite(); } return true; } } catch (IOException e) { onTransportFailure(e); return false; } }
public boolean offer(Object command) { assert Dispatch.getCurrentQueue() == dispatchQueue; try { if (!socketState.isConnected()) { throw new IOException("Not connected."); } if (!getServiceState().isStarted()) { throw new IOException("Not running."); } ProtocolCodec.BufferState rc = codec.write(command); switch (rc ) { case FULL: return false; default: if( drained ) { drained = false; resumeWrite(); } return true; } } catch (IOException e) { onTransportFailure(e); return false; } }
@Override public void destroy(final Task cb) { StoreUOW uow = store.create_uow(); uow.put(session_key, null); final DispatchQueue current = Dispatch.getCurrentQueue(); uow.on_complete(Scala2Java.toScala(new UnitFn0() { @Override public void call() { current.execute(new Task() { @Override public void run() { strategy = new NoopStrategy(); cb.run(); } }); } })); uow.release(); }
/** * */ protected void drainOutbound() { assert Dispatch.getCurrentQueue() == dispatchQueue; if (getServiceState() != STARTED || !socketState.is(CONNECTED.class)) { return; } try { if( codec.flush() == ProtocolCodec.BufferState.WAS_EMPTY && flush() ) { if( !drained ) { drained = true; suspendWrite(); listener.onRefill(this); } } } catch (IOException e) { onTransportFailure(e); } }
/** * */ protected void drainOutbound() { assert Dispatch.getCurrentQueue() == dispatchQueue; if (!getServiceState().isStarted() || !socketState.isConnected()) { return; } try { if( codec.flush() == ProtocolCodec.BufferState.WAS_EMPTY && flush() ) { if( !drained ) { drained = true; suspendWrite(); listener.onRefill(this); } } } catch (IOException e) { onTransportFailure(e); } }
final DispatchQueue current = Dispatch.getCurrentQueue(); uow.on_complete(Scala2Java.toScala(new UnitFn0() { @Override