Thanks @Araq, addQuitProc is one the procs I was looking for. I don't thinks
I'll hit limit of 30 procs, so It'll probably suffice. Is there anything more
generic that I can use for SIGHUP, to reload?
I'm implementing a queue of procs to call when SIGHUP is received, but adding
an obj to a global seq from an inherited instance raises ObjectAssignmentError
in lib/system/assign.nim(97) genericAssignAux. I can add a ptr obj, but when I
cast it back, it "loses" the inheritance, and doesn't call the right method.
A minimal example:
type
App* = object of RootObj
running*: bool
PType = proc(app: App): bool {.nimcall.}
PTuple = tuple[app: App, f: PType]
BApp = object of App
var s = newSeq[PTuple]()
method reload*(app: App): bool {.base.} =
echo "App reloaded"
true
proc start*(app: App) =
s.add((app, reload))
echo repr(s)
proc stop*(app: App) =
for e in s:
discard e.f(cast[App](e.app))
method reload*(app: var App): bool =
echo "BApp reloaded"
return true
when isMainModule:
var app = BApp()
app.start
app.stop
Run