Currently, I couldn't find a way to Marshal/Unmarshal directly from/to byte array using MsgPack.
Is there a way to achieve this without specify a Reader/Writer/Stream beforehand in constructor ?
I can use the ResetBytes function to achieve this but if I have an Encoder/Decoder that share among multiple goroutines, this could be a problem because the underlying []byte is not thread-safe.
I have tried to run a test with allocation a new Encoder/Decoder everytime I have a new []byte array to work with, but that allocation process resulted in doubling the serialisation time.
You should allocate a new one, or reuse one but ensure that only one person is using it at a time (using an exclusive mutex or a sync.Pool where you grab one, use it and return it to the pool).
Hi ugorji,
Currently, I couldn't find a way to Marshal/Unmarshal directly from/to byte array using MsgPack. Is there a way to achieve this without specify a Reader/Writer/Stream beforehand in constructor ?
I can use the ResetBytes function to achieve this but if I have an Encoder/Decoder that share among multiple goroutines, this could be a problem because the underlying []byte is not thread-safe.
I have tried to run a test with allocation a new Encoder/Decoder everytime I have a new []byte array to work with, but that allocation process resulted in doubling the serialisation time.