That's good news.
I thought so because I got deprecated error messages coming from the locks module that seemed to say so. I will start using them again, and post the error messages here.
import tables, locks, osproc
type
Killer = object
lock: TLock
bailed {.guard: lock.}: bool
processes {.guard: lock.}: Table[int, Process]
template hold(lock: TLock; body: stmt) =
lock.acquire
defer: lock.release
{.locks: [lock].}:
body
# Initialize a Killer.
proc initKiller(): Killer =
initLock(result.lock)
result.lock.hold:
result.bailed = false
result.processes = initTable[int, Process]()
# remember that a process has been launched, killing it if we have bailed.
proc launched(killer: var Killer, process: Process) =
killer.lock.hold:
if killer.bailed:
process.terminate()
else:
killer.processes[process.processId] = process
# A process has been finished with.
proc completed(killer: var Killer, process: Process) =
killer.lock.hold:
killer.processes.del(process.processId)
# Bail, doing nothing if already bailed.
proc bail(killer: var Killer): bool =
killer.lock.hold:
result = not killer.bailed
if not killer.bailed:
killer.bailed = true
for id, process in killer.processes:
process.terminate
killer.processes = initTable[int, Process]()
# Global Killer instance.
var killer = initKiller()
When I compile this with default options, I get these warnings that I don't understand:
lib/core/locks.nim(22, 43) Warning: LockEffect is deprecated [Deprecated] lib/core/locks.nim(25, 44) Warning: LockEffect is deprecated [Deprecated]
Note that heaps of other deprecated warnings come out of the library modules, so I have to turn Deprecated and some other warnings off - but I would like to know what this one means.