Add FacetGuard
This commit is contained in:
parent
82f2e8ee98
commit
cd846d0d46
|
@ -685,3 +685,23 @@ proc run* =
|
||||||
except CatchableError as err:
|
except CatchableError as err:
|
||||||
stderr.writeLine "ioqueue continuation threw an error"
|
stderr.writeLine "ioqueue continuation threw an error"
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
|
type FacetGuard* = object
|
||||||
|
facet: Facet
|
||||||
|
|
||||||
|
proc initGuard*(f: Facet): FacetGuard =
|
||||||
|
result.facet = f
|
||||||
|
inc result.facet.inertCheckPreventers
|
||||||
|
|
||||||
|
proc disarm*(g: var FacetGuard) =
|
||||||
|
if not g.facet.isNil:
|
||||||
|
assert g.facet.inertCheckPreventers > 0
|
||||||
|
dec g.facet.inertCheckPreventers
|
||||||
|
g.facet = nil
|
||||||
|
|
||||||
|
proc `=destroy`*(g: var FacetGuard) =
|
||||||
|
disarm(g)
|
||||||
|
|
||||||
|
proc `=copy`*(dst: var FacetGuard, src: FacetGuard) =
|
||||||
|
dst.facet = src.facet
|
||||||
|
inc dst.facet.inertCheckPreventers
|
||||||
|
|
Loading…
Reference in New Issue