Merge pull request #160 from vibe-d/leastsize_timeout
Let TCPConnection.leastSize time out according to the readTimeout property merged-on-behalf-of: Leonid Kramer <l-kramer@users.noreply.github.com>
This commit is contained in:
commit
b68c8b12f9
|
@ -553,7 +553,18 @@ struct TCPConnection {
|
||||||
return s >= ConnectionState.connected && s < ConnectionState.activeClose;
|
return s >= ConnectionState.connected && s < ConnectionState.activeClose;
|
||||||
}
|
}
|
||||||
@property bool empty() { return leastSize == 0; }
|
@property bool empty() { return leastSize == 0; }
|
||||||
@property ulong leastSize() { waitForData(); return m_context ? m_context.readBuffer.length : 0; }
|
|
||||||
|
@property ulong leastSize()
|
||||||
|
{
|
||||||
|
if (!m_context) return 0;
|
||||||
|
|
||||||
|
auto res = waitForDataEx(m_context.readTimeout);
|
||||||
|
if (res == WaitForDataStatus.timeout)
|
||||||
|
throw new ReadTimeoutException("Read operation timed out");
|
||||||
|
|
||||||
|
return m_context.readBuffer.length;
|
||||||
|
}
|
||||||
|
|
||||||
@property bool dataAvailableForRead() { return waitForData(0.seconds); }
|
@property bool dataAvailableForRead() { return waitForData(0.seconds); }
|
||||||
|
|
||||||
void close()
|
void close()
|
||||||
|
|
Loading…
Reference in a new issue