Skip to content

Commit

Permalink
Just define getIoHandler for HackDispatcher instead of using when
Browse files Browse the repository at this point in the history
Simplifies it and feels less hacky

Remove the type that Araq says sn't required
  • Loading branch information
ire4ever1190 committed Jun 5, 2023
1 parent 59e1c9a commit d84fc38
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions asynctools/asyncipc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ elif defined(windows):
ioPort: Handle
handles: HashSet[AsyncFD]
HackDispatcher = ptr HackDispatcherImpl
Dispatcher = HackDispatcher | PDispatcher

proc openEvent(dwDesiredAccess: Dword, bInheritHandle: WINBOOL,
lpName: WideCString): Handle
Expand All @@ -143,7 +142,7 @@ elif defined(windows):
proc interlockedAnd(a: ptr int32, b: int32)
{.importc: "_InterlockedAnd", header: "intrin.h".}

proc getCurrentDispatcher(): Dispatcher =
proc getCurrentDispatcher(): auto =
when defined(nimv2):
# New runtime will run into segfault if using HackDispatcher, but old versions of Nim require
# HackDispatcher so we can access some internal fields.
Expand All @@ -153,12 +152,9 @@ elif defined(windows):
else:
cast[HackDispatcher](getGlobalDispatcher())

template getIoHandler(p: Dispatcher): Handle =
template getIoHandler(p: HackDispatcher): Handle =
## Returns the IO handle for a dispatcher.
when p is PDispatcher:
p.getIoHandler()
else:
p.ioPort
p.ioPort

proc `$`*(ipc: AsyncIpc): string =
if ipc.handleMap == Handle(0):
Expand Down

0 comments on commit d84fc38

Please sign in to comment.