Nim-1.6 fixes (#239)

This commit is contained in:
Ștefan Talpalaru 2021-11-20 01:30:23 +01:00 committed by GitHub
parent f51158da65
commit 4aaaa3379a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -323,7 +323,7 @@ when defined(windows) or defined(nimdoc):
AsyncFD* = distinct int
proc hash(x: AsyncFD): Hash {.borrow.}
proc `==`*(x: AsyncFD, y: AsyncFD): bool {.borrow.}
proc `==`*(x: AsyncFD, y: AsyncFD): bool {.borrow, gcsafe.}
proc getFunc(s: SocketHandle, fun: var pointer, guid: var GUID): bool =
var bytesRet: DWORD
@ -516,7 +516,7 @@ elif unixPlatform:
selector: Selector[SelectorData]
keys: seq[ReadyKey]
proc `==`*(x, y: AsyncFD): bool {.borrow.}
proc `==`*(x, y: AsyncFD): bool {.borrow, gcsafe.}
proc globalInit() =
# We are ignoring SIGPIPE signal, because we are working with EPIPE.

View File

@ -571,8 +571,10 @@ proc emit[T](bus: AsyncEventBus, event: string, data: T, loc: ptr SrcLoc) =
# Schedule subscriber's callbacks, which are subscribed to the event.
for subscriber in item.subscribers:
# Nim-1.6 says: "'subscriber' is of type <lent EventBusKey> which cannot be captured as it would violate memory safety"
let subscriber_copy = subscriber
callSoon(proc(udata: pointer) =
subscriber.cb(bus, event, subscriber, payload)
subscriber_copy.cb(bus, event, subscriber_copy, payload)
)
# Schedule waiters which are waiting all events
@ -583,8 +585,10 @@ proc emit[T](bus: AsyncEventBus, event: string, data: T, loc: ptr SrcLoc) =
# Schedule subscriber's callbacks which are subscribed to all events.
for subscriber in bus.subscribers:
# Nim-1.6 says: "'subscriber' is of type <lent EventBusKey> which cannot be captured as it would violate memory safety"
let subscriber_copy = subscriber
callSoon(proc(udata: pointer) =
subscriber.cb(bus, event, subscriber, payload)
subscriber_copy.cb(bus, event, subscriber_copy, payload)
)
template emit*[T](bus: AsyncEventBus, event: string, data: T) =

View File

@ -1642,7 +1642,7 @@ else:
break
return retFuture
proc acceptLoop(udata: pointer) =
proc acceptLoop(udata: pointer) {.gcsafe.} =
var
saddr: Sockaddr_storage
slen: SockLen