BeginDeserialize/EndDeserialize
llint opened this issue · comments
Currently MsgPack.Deserialize
eventually invokes Stream.Read
which is blocking. It would be great if there is an asynchronous version BeginDeserialize<T>/EndDeserialize<T>
that takes advantage of Stream.BeginRead
/ Stream.EndRead
, so to make the operation asynchronous.
This is good enough for Unity3D (.NET 3.5). For higher version of the runtime (e.g. the experimental .NET 4.6), of course the TAP APIs can be added over the foundational Begin/End async API.
Currently to avoid blocking, I have to create a MemoryStream, asynchronously read (BeginRead
/EndRead
) from the NetworkStream
, and copy the data into the MemoryStream
object, and invoke MsgPack.Deserialize
on the MemoryStream
to make the operation fully asynchronous.
Hi @llint. Unfortunately I can not add this feature. it will require rewriting every layer of serialization/de-serialization code because stream at lowest layer.
- User API (you are interacting with it)
- TypeSerializer
- Tokenizer
- Stream
As I remember even json.NET doesn't support async serialization/de-serialization.
Currently to avoid blocking, I have to create a MemoryStream, asynchronously read (BeginRead/EndRead) from the NetworkStream, and copy the data into the MemoryStream object, and invoke.
Yep, this is only solution for this scenario if you want to avoid blocking.