feat: copy mode for decoder and Copy method for encoder #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
主要考虑是并发场景下使用encoder和decoder.
目前decoder使用的
[]byte
数据均指向原input buffer, 如果这个buffer是个固定的收报buffer, 那么这个buffer改变, decoder引用的数据就会改变, decode的结果就会改变. copy mode就是把需要的[]byte
部分从原buffer拷贝一份.encoder的Copy方法是拷贝当前encoder, 但使用新的buffer. 这样一个encoder就可以在并发场景下copy后使用.