Skip to content

Commit

Permalink
Don't use destructors
Browse files Browse the repository at this point in the history
  • Loading branch information
zah committed Apr 22, 2020
1 parent f3d1c88 commit caab5c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions faststreams/input_stream.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ proc close*(s: InputStream) {.raises: [IOError, Defect].} =

s.preventFurtherReading()

# TODO
# The destructors are currently disabled because they seem to cause
# mysterious segmentation faults related to corrupted GC internal
# data structures.
#[
proc `=destroy`*(h: var InputStreamHandle) {.raises: [Defect].} =
if h.s != nil:
if h.s.vtable != nil and h.s.vtable.closeSync != nil:
Expand All @@ -82,6 +87,7 @@ proc `=destroy`*(h: var InputStreamHandle) {.raises: [Defect].} =
# We work-around the problem through more indirect incapacitatation
# of the stream object:
h.s.preventFurtherReading()
]#

converter implicitDeref*(h: InputStreamHandle): InputStream =
h.s
Expand Down
6 changes: 6 additions & 0 deletions faststreams/output_stream.nim
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ proc close*(s: OutputStream) {.raises: [IOError, Defect].} =
if s.vtable != nil and s.vtable.closeSync != nil:
s.vtable.closeSync(s)

# TODO
# The destructors are currently disabled because they seem to cause
# mysterious segmentation faults related to corrupted GC internal
# data structures.
#[
proc `=destroy`*(h: var OutputStreamHandle) {.raises: [Defect].} =
if h.s != nil:
if h.s.vtable != nil and h.s.vtable.closeSync != nil:
Expand All @@ -83,6 +88,7 @@ proc `=destroy`*(h: var OutputStreamHandle) {.raises: [Defect].} =
# `close` manually.
discard # TODO
# h.s = nil
]#

converter implicitDeref*(h: OutputStreamHandle): OutputStream =
h.s
Expand Down

0 comments on commit caab5c9

Please sign in to comment.