francoispqt / gojay

high performance JSON encoder/decoder with stream API for Golang
MIT License
2.11k stars 112 forks source link

Use writer lock for cancel. #98

Closed OGKevin closed 5 years ago

OGKevin commented 5 years ago

Fixes #97

By using the writer lock, you ensure that close is called only once. Closing the chan should be seen as a write operation and not a read operation.

By using the read lock, there is a possibility that concurrent calls to cancel will cause a panic. Using a write lock fixes this.

codecov-io commented 5 years ago

Codecov Report

Merging #98 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master     #98   +/-   ##
======================================
  Coverage    98.7%   98.7%           
======================================
  Files          36      36           
  Lines        5189    5189           
======================================
  Hits         5122    5122           
  Misses         52      52           
  Partials       15      15
Impacted Files Coverage Δ
encode_stream.go 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 90d9533...92f89c6. Read the comment docs.

OGKevin commented 5 years ago

hey @francoispqt whats the status on this PR?