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
|
type
|
||||||
MultisteamSelectException = object of CatchableError
|
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
|
Matcher* = proc (proto: string): bool
|
||||||
|
|
||||||
HandlerHolder* = object
|
HandlerHolder* = object
|
||||||
|
|
|
@ -12,7 +12,7 @@ import connection, transport, stream,
|
||||||
peerinfo, multiaddress, multistreamselect,
|
peerinfo, multiaddress, multistreamselect,
|
||||||
switchtypes
|
switchtypes
|
||||||
|
|
||||||
proc newProtocol*(p: typedesc[Protocol],
|
proc newProtocol*(p: typedesc[switchtypes.Protocol],
|
||||||
peerInfo: PeerInfo,
|
peerInfo: PeerInfo,
|
||||||
switch: Switch): p =
|
switch: Switch): p =
|
||||||
new result
|
new result
|
||||||
|
@ -20,10 +20,7 @@ proc newProtocol*(p: typedesc[Protocol],
|
||||||
result.switch = switch
|
result.switch = switch
|
||||||
result.init()
|
result.init()
|
||||||
|
|
||||||
method init*(p: Protocol) {.base.} = discard
|
method init*(p: switchtypes.Protocol) {.base.} = discard
|
||||||
|
|
||||||
method dial*(p: Protocol, peerInfo: PeerInfo): Future[Connection]
|
method handle*(p: switchtypes.Protocol, peerInfo: PeerInfo, handler: ProtoHandler)
|
||||||
{.base, async, error: "not implemented!".} = discard
|
|
||||||
|
|
||||||
method handle*(p: Protocol, peerInfo: PeerInfo, handler: ProtoHandler)
|
|
||||||
{.base, async, error: "not implemented!".} = discard
|
{.base, async, error: "not implemented!".} = discard
|
||||||
|
|
|
@ -9,16 +9,16 @@
|
||||||
|
|
||||||
import chronos
|
import chronos
|
||||||
import transport, wire, connection,
|
import transport, wire, connection,
|
||||||
multiaddress, connection,
|
multiaddress, connection,
|
||||||
multicodec, chronosstream
|
multicodec, chronosstream
|
||||||
|
|
||||||
type TcpTransport* = ref object of Transport
|
type TcpTransport* = ref object of Transport
|
||||||
server*: StreamServer
|
server*: StreamServer
|
||||||
|
|
||||||
method connHandler*(t: Transport,
|
proc connHandler*(t: Transport,
|
||||||
server: StreamServer,
|
server: StreamServer,
|
||||||
client: StreamTransport): Future[Connection]
|
client: StreamTransport): Future[Connection]
|
||||||
{.base, gcsafe, async.} =
|
{.gcsafe, async.} =
|
||||||
let conn: Connection = newConnection(newChronosStream(server, client))
|
let conn: Connection = newConnection(newChronosStream(server, client))
|
||||||
let handlerFut = if t.handler == nil: nil else: t.handler(conn)
|
let handlerFut = if t.handler == nil: nil else: t.handler(conn)
|
||||||
let connHolder: ConnHolder = ConnHolder(connection: conn,
|
let connHolder: ConnHolder = ConnHolder(connection: conn,
|
||||||
|
|
Loading…
Reference in New Issue