This change was done to avoid confusion with TCP/IP raw sockets. Native sockets
module represents handling native system low level socket API in general and is
not just limited anyhow to TCP/IP raw sockets.
A stub lib/deprecated/pure/rawsockets.nim module has been added as
compatibility layer for old code using rawsockets, so this change will not
break existing code.
Exporting newSocket(fd) mimics what asyncnet does and lets you pass in your
own socket FD.
newSocket*(fd) and newAsyncSocket*(fd) now both take "buffered" instead of
"isBuff" and defaults to true to match the other constructors on both.
FutureVar[T] is a new distinct Future type which is designed to be used
for situations where the highest performance is needed. It reduces the
number of Future allocations needed. It acts as a replacement for
'var' params in async procs.
This commit modifies @def-'s PR in order to make it safer. The recvLineInto
procedure has been modified to take a ``FutureVar[string]`` param instead of a
``ptr string`` param.
- Export socket field of AsyncHttpServer and addHeaders proc for templates
- Make respond a template instead of proc because of how often it's called.
This means no more "await" when invoking it.
- Optimize respond template with special case for empty headers and
Content-Length entry
- newRequest doesn't allocate a hostname and body anymore because they're
copied in later
- Major changes to processClient to prevent allocations and copies
- readInto, readIntoBuf, are templates instead of procs now
- New recvLineInto template that reads directly into a string instead of
creating a new one. Used by recvLine proc now
- Need fd and bufLen fields of AsyncSocketDesc exported because of the
templates
- recv returns a shallow string to prevent copying
- This gives significant speedups, mostly by using templates instead of
creating new Futures and waiting for them all the time.
The tasyncexceptions test has been added which tests for this incorrect
exception handling behaviour. The problem was that the exception was
raised inside a callback which was called from a previously finished async
procedure. This caused a "Future already finished" error. The fix was to
simply reraise the exception if the retFutureSym is already finished.
sleepAsync was added to help with the reproduction of this test. It should
also be useful for users however.
Finally some debug information was added to futures to help with future
bugs.
* Selectors implementation will now attempt to immediately execute an IO
operation instead of waiting for a ready notification.
* Removed recursion in asynchttpserver.
* Improved buffered implementation of recvLine in asyncnet.
* Optimised ``respond`` in asynchttpserver removing a possible "Delayed ACK"
situation.