attempt to make asynchttpserver better; fixes #15925; [backport:1.0]
This commit is contained in:
parent
778914c3ca
commit
8778d4a6f3
7 changed files with 123 additions and 50 deletions
|
|
@ -1934,3 +1934,25 @@ proc waitFor*[T](fut: Future[T]): T =
|
|||
poll()
|
||||
|
||||
fut.read
|
||||
|
||||
proc activeDescriptors*(): int {.inline.} =
|
||||
## Returns the current number of active file descriptors for the current
|
||||
## event loop. This is a cheap operation that does not involve a system call.
|
||||
when defined(windows):
|
||||
result = getGlobalDispatcher().handles.len
|
||||
else:
|
||||
result = getGlobalDispatcher().selector.count
|
||||
|
||||
when defined(posix):
|
||||
import posix
|
||||
|
||||
proc maxDescriptors*(): int {.raises: OSError.} =
|
||||
## Returns the maximum number of active file descriptors for the current
|
||||
## process. This involves a system call.
|
||||
when defined(windows):
|
||||
result = 16_700_000
|
||||
else:
|
||||
var fdLim: RLimit
|
||||
if getrlimit(RLIMIT_NOFILE, fdLim) < 0:
|
||||
raiseOSError(osLastError())
|
||||
result = int(fdLim.rlim_cur) - 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue