mirror of https://github.com/vacp2p/nim-libp2p.git
use gcsafe in closures
This commit is contained in:
parent
b56b005ab7
commit
a7709b8afc
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
|
||||
import chronos
|
||||
import transport, wire, connection,
|
||||
multiaddress, connection,
|
||||
multicodec, chronosstream
|
||||
multiaddress, connection,
|
||||
multicodec, chronosstream
|
||||
|
||||
type TcpTransport* = ref object of Transport
|
||||
server*: StreamServer
|
||||
|
||||
method connHandler*(t: Transport,
|
||||
server: StreamServer,
|
||||
client: StreamTransport): Future[Connection]
|
||||
{.base, gcsafe, async.} =
|
||||
proc connHandler*(t: Transport,
|
||||
server: StreamServer,
|
||||
client: StreamTransport): Future[Connection]
|
||||
{.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,
|
||||
|
|
Loading…
Reference in New Issue