问题描述
在protobuf网实现的一个局限在于,它调用底层流同步。如果不提供异步API,例如BeginSerialize / EndSerialize或TPL等同,我们不得不占用一个线程等待同步I / O流。
A limitation of the protobuf-net implementation is that it calls the underlying streams synchronously. By not offering an asynchronous API e.g. BeginSerialize/EndSerialize or a TPL equivalent, we are forced to tie up a thread waiting for synchronous stream I/O.
有没有计划提供解决此问题的异步方法protobuf网,或者,任何创造性的方式?
Is there any plan to offer asynchronous methods in protobuf-net, or alternatively, any creative ways around this problem?
推荐答案
没有,目前不支持,将是一个很多的工作。
No, that isn't currently supported and would be a lot of work.
我的建议是:自己使用缓冲区中的数据异步的API,然后的在的你的数据,使用的东西就像一个的MemoryStream
来反序列化...
My suggestion would be: buffer data yourself using the async APIs, and then when you have the data, use something like a MemoryStream
to deserialize...
在我的防守,我不知道有任何的等的序列化,这里提供了一个异步的API。特别是,在谈论缓/异步流,那的时,通常的意思是网络:你通常有框架的需要考虑的问题有; protobuf网将不知道你的取景要求...
In my defence, I'm not aware of any other serializer that offers an async API here. In particular, when talking about slow/async streams, that usually means "network": and you usually have the issue of "framing" to consider there; protobuf-net won't know your framing requirements...
这篇关于异步protobuf的系列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!