use gcsafe in closures

This commit is contained in:
Dmitriy Ryajov 2019-08-28 13:03:58 -06:00
parent b56b005ab7
commit a7709b8afc
3 changed files with 10 additions and 13 deletions

View File

@ -20,7 +20,7 @@ const Ls = "\x03ls\n"
type
MultisteamSelectException = object of CatchableError
Handler* = proc (conn: Connection, proto: string): Future[void]
Handler* = proc (conn: Connection, proto: string): Future[void] {.gcsafe.}
Matcher* = proc (proto: string): bool
HandlerHolder* = object

View File

@ -12,7 +12,7 @@ import connection, transport, stream,
peerinfo, multiaddress, multistreamselect,
switchtypes
proc newProtocol*(p: typedesc[Protocol],
proc newProtocol*(p: typedesc[switchtypes.Protocol],
peerInfo: PeerInfo,
switch: Switch): p =
new result
@ -20,10 +20,7 @@ proc newProtocol*(p: typedesc[Protocol],
result.switch = switch
result.init()
method init*(p: Protocol) {.base.} = discard
method init*(p: switchtypes.Protocol) {.base.} = discard
method dial*(p: Protocol, peerInfo: PeerInfo): Future[Connection]
{.base, async, error: "not implemented!".} = discard
method handle*(p: Protocol, peerInfo: PeerInfo, handler: ProtoHandler)
method handle*(p: switchtypes.Protocol, peerInfo: PeerInfo, handler: ProtoHandler)
{.base, async, error: "not implemented!".} = discard

View File

@ -15,10 +15,10 @@ import transport, wire, connection,
type TcpTransport* = ref object of Transport
server*: StreamServer
method connHandler*(t: Transport,
proc connHandler*(t: Transport,
server: StreamServer,
client: StreamTransport): Future[Connection]
{.base, gcsafe, async.} =
{.gcsafe, async.} =
let conn: Connection = newConnection(newChronosStream(server, client))
let handlerFut = if t.handler == nil: nil else: t.handler(conn)
let connHolder: ConnHolder = ConnHolder(connection: conn,