public object get(Duration timeout) { object r = null; try { lock (this) { // wait until we enter a done state, the only notifies // on this object should be from cancel, set, or err if (timeout == null) { // wait forever until done while ((m_state & DONE) == 0) { Monitor.Wait(this); } } else { // if not done, then wait with timeout and then // if still not done throw a timeout exception if ((m_state & DONE) == 0) { Monitor.Wait(this, (int)timeout.millis()); if ((m_state & DONE) == 0) { throw TimeoutErr.make("Future.get timed out").val; } } } // if canceled throw CancelErr if (m_state == DONE_CANCEL) { throw CancelledErr.make("message canceled").val; } // if error was raised, raise it to caller if (m_state == DONE_ERR) { throw ((Err)m_result).rebase(); } // assign result to local variable for return r = m_result; } } catch (ThreadInterruptedException e) { throw InterruptedErr.make(e).val; } // ensure immutable or safe copy return(Sys.safe(r)); }
public ActorPool join(Duration timeout) { if (!isStopped()) { throw Err.make("ActorPool is not stopped").val; } long ms = timeout == null ? System.Int32.MaxValue : timeout.millis(); try { if (m_threadPool.join(ms)) { return(this); } } catch (System.Threading.ThreadInterruptedException e) { throw InterruptedErr.make(e).val; } throw TimeoutErr.make("ActorPool.join timed out").val; }
public ActorPool join(Duration timeout) { if (!isStopped()) throw Err.make("ActorPool is not stopped").val; long ms = timeout == null ? System.Int32.MaxValue : timeout.millis(); try { if (m_threadPool.join(ms)) return this; } catch (System.Threading.ThreadInterruptedException e) { throw InterruptedErr.make(e).val; } throw TimeoutErr.make("ActorPool.join timed out").val; }
public object get(Duration timeout) { object r = null; try { lock (this) { // wait until we enter a done state, the only notifies // on this object should be from cancel, set, or err if (timeout == null) { // wait forever until done while ((m_state & DONE) == 0) Monitor.Wait(this); } else { // if not done, then wait with timeout and then // if still not done throw a timeout exception if ((m_state & DONE) == 0) { Monitor.Wait(this, (int)timeout.millis()); if ((m_state & DONE) == 0) throw TimeoutErr.make("Future.get timed out").val; } } // if canceled throw CancelErr if (m_state == DONE_CANCEL) throw CancelledErr.make("message canceled").val; // if error was raised, raise it to caller if (m_state == DONE_ERR) throw ((Err)m_result).rebase(); // assign result to local variable for return r = m_result; } } catch (ThreadInterruptedException e) { throw InterruptedErr.make(e).val; } // ensure immutable or safe copy return Sys.safe(r); }
public void setReceiveTimeout(TcpSocket fan, Duration v) { if (v == null) m_dotnet.ReceiveTimeout = 0; else m_dotnet.ReceiveTimeout = (int)(v.millis()); }
public TcpSocket connect(TcpSocket fan, IpAddr addr, long port, Duration timeout) { if (timeout != null) { IAsyncResult result = m_dotnet.BeginConnect(addr.m_peer.m_dotnet, (int)port, null, null); bool success = result.AsyncWaitHandle.WaitOne((int)timeout.millis(), true); if (!success) { m_dotnet.Close(); throw new System.IO.IOException("Connection timed out."); } } else { m_dotnet.Connect(addr.m_peer.m_dotnet, (int)port); } connected(fan); return fan; }
public void setReceiveTimeout(TcpListener fan, Duration v) { m_timeout = (v == null) ? 0 : (int)(v.millis()); }
public void setReceiveTimeout(UdpSocket fan, Duration v) { m_receiveTimeout = (v == null) ? 0 : (int)v.millis(); }