コード例 #1
1
 /** Shut down communication with the autosampler. */
 public void disconnect() {
   if (m_reader != null) {
     m_reader.quit();
     m_reader.interrupt();
   }
   if (m_sender != null) {
     m_sender.quit();
     m_sender.interrupt();
   }
   if (m_statusPoller != null) {
     m_statusPoller.quit();
     m_statusPoller.interrupt();
   }
   if (m_CryoSocket != null) {
     m_CryoSocket.disconnect();
     m_CryoSocket = null;
   }
 }
コード例 #2
0
 /**
  * Send a command to the cryobay.
  *
  * @param commandMessage The string to send to the cryobay.
  * @return True if there is a connection to the cryobay
  */
 public synchronized boolean sendToCryoBay(String command) {
   if (m_sender == null) {
     m_sender = new Sender(null, m_retries, this);
     m_sender.start();
   }
   if (isConnected()) {
     m_sender.addCommand(command);
     // TODO: (Java 5) Release semaphore here
     // m_sender.interrupt(); // Wake up the run() method
     return true;
   } else {
     return false;
   }
 }
コード例 #3
0
ファイル: TcpConnection.java プロジェクト: fornava/JGroups
 /**
  * @param data Guaranteed to be non null
  * @param offset
  * @param length
  */
 public void send(byte[] data, int offset, int length) throws Exception {
   if (sender != null) {
     byte[] copy = new byte[length];
     System.arraycopy(data, offset, copy, 0, length);
     sender.addToQueue(new Buffer(copy, 0, length));
   } else _send(data, offset, length, true, true);
 }
コード例 #4
0
ファイル: TcpConnection.java プロジェクト: fornava/JGroups
  public void start() {
    if (receiver != null) receiver.stop();
    receiver = new Receiver(server.factory).start();

    if (isSenderUsed()) {
      if (sender != null) sender.stop();
      sender = new Sender(server.factory, server.sendQueueSize()).start();
    }
  }
コード例 #5
0
 /**
  * @param data Guaranteed to be non null
  * @param offset
  * @param length
  */
 private void send(byte[] data, int offset, int length) throws Exception {
   if (isSenderUsed()) {
     // we need to copy the byte[] buffer here because the original buffer might get
     // changed meanwhile
     byte[] tmp = new byte[length];
     System.arraycopy(data, offset, tmp, 0, length);
     sender.addToQueue(tmp);
   } else {
     _send(data, offset, length, true);
   }
 }
コード例 #6
0
  /**
   * Does the work for processReply.
   *
   * @see #processReply
   */
  private void processReplyInEventThread(String what, boolean value) {

    //        Messages.postDebug("cryocmd", "CryoSocketControl.processReply("
    //                           + what + ", " + value + ")");

    if (debug) System.out.println("CryoSocketControl.gotReply: " + what);
    if (what != null) {
      m_sender.gotReply(value);
      processStatus(what, value);
    }
  }
コード例 #7
0
    private void start(ThreadFactory f) {
      // only start once....
      if (active.compareAndSet(false, true)) {
        connectionPeerReceiver = new ConnectionPeerReceiver(f);
        connectionPeerReceiver.start();

        if (isSenderUsed()) {
          sender = new Sender(f, getSenderQueueSize());
          sender.start();
        }
      }
    }
コード例 #8
0
 public void close() throws IOException {
   // can close even if start was never called...
   send_lock.lock();
   try {
     connectionPeerReceiver.stop();
     if (isSenderUsed()) {
       sender.stop();
     }
     Util.close(sock);
     Util.close(out);
     Util.close(in);
   } finally {
     send_lock.unlock();
   }
   mapper.notifyConnectionClosed(peer_addr);
 }
コード例 #9
0
ファイル: TcpConnection.java プロジェクト: fornava/JGroups
 public void close() throws IOException {
   send_lock.lock();
   try {
     Util.close(out, in, sock);
     if (receiver != null) {
       receiver.stop();
       receiver = null;
     }
     if (sender != null) {
       sender.stop();
       sender = null;
     }
   } finally {
     send_lock.unlock();
   }
 }
コード例 #10
0
 public boolean isOpen() {
   return isConnected()
       && (!isSenderUsed() || sender.isRunning())
       && (connectionPeerReceiver != null && connectionPeerReceiver.isRunning());
 }
コード例 #11
0
ファイル: Substrate.java プロジェクト: Kleagleguo/kleagle
 /**
  * Test if substrate is ready to send more packets.
  *
  * @return true if substrate is ready
  */
 public boolean ready() {
   return sndr.ready();
 }
コード例 #12
0
ファイル: Substrate.java プロジェクト: Kleagleguo/kleagle
 /**
  * Send a packet.
  *
  * @param p is a packet to be sent
  */
 public void send(Packet p) {
   sndr.send(p);
 }
コード例 #13
0
ファイル: Substrate.java プロジェクト: Kleagleguo/kleagle
 /** Wait for Substrate to stop. */
 public void join() throws Exception {
   sndr.join();
   rcvr.join();
 }
コード例 #14
0
ファイル: Substrate.java プロジェクト: Kleagleguo/kleagle
 /** Start Substrate running. */
 public void start() {
   sndr.start();
   rcvr.start();
 }