/** * Perform the given command in such a way that it does not run * concurrently with the transport thread or other commands * performed by invoking this method. This method will continue to * work even after the transport thread has been shut down. * * @param cmd the command to perform **/ public void perform(Runnable cmd) { if (Thread.currentThread() == thread) { cmd.run(); return; } if (!postCommand(cmd)) { join(); synchronized (thread) { cmd.run(); } } }
@Override public void destroy() { if (destroyed.getAndSet(true)) throw new RuntimeException("Already destroyed"); mirror.shutdown(); orb.transport().shutdown().join(); }
public void shutdown() { configSubscriber.close(); supervisor.transport().shutdown().join(); }
public void stop() { orb.transport().shutdown().join(); listener.shutdown().join(); }
/** * Synchronize with the transport thread. This method will block * until all commands issued before this method was invoked has * completed. If the transport thread has been shut down (or is in * the progress of being shut down) this method will instead wait * for the transport thread to complete, since no more commands * will be performed, and waiting would be forever. Invoking this * method from the transport thread is not a good idea. * * @return this object, to enable chaining **/ public Transport sync() { SyncCmd cmd = new SyncCmd(); if (postCommand(cmd)) { cmd.waitDone(); } else { join(); } return this; }
private void unregisterInSlobrok() { if (slobrokRegistrator != null) slobrokRegistrator.shutdown(); if (acceptor != null) acceptor.shutdown().join(); if (supervisor != null) supervisor.transport().shutdown().join(); }
/** * Sets the destroyed flag to true. The very first time this method is called, it cleans up all its dependencies. * Even if you retain a reference to this object, all of its content is allowed to be garbage collected. * * @return True if content existed and was destroyed. */ public boolean destroy() { if (!destroyed.getAndSet(true)) { if (slobroksConfig != null) { slobroksConfig.shutdown(); } register.shutdown(); mirror.shutdown(); listener.shutdown().join(); orb.transport().shutdown().join(); targetPool.flushTargets(true); executor.shutdown(); return true; } return false; }
public Slobrok(int port) throws ListenFailedException { orb = new Supervisor(new Transport()); registerMethods(); try { listener = orb.listen(new Spec(port)); } catch (ListenFailedException e) { orb.transport().shutdown().join(); throw e; } }
target.close(); if (supervisor!=null) supervisor.transport().shutdown().join();
listener = orb.listen(new Spec(params.getListenPort())); } catch (ListenFailedException e) { orb.transport().shutdown().join(); throw new RuntimeException(e);