开发者

What is the most efficient way of storing data read from a socket to be read by another thread?

开发者 https://www.devze.com 2023-04-10 07:57 出处:网络
So I have a class using high speed I/O completion port sockets. The protocol of the data I am receiving has a 17 byte header, and a variable data payload which is specified in the header, so instead o

So I have a class using high speed I/O completion port sockets. The protocol of the data I am receiving has a 17 byte header, and a variable data payload which is specified in the header, so instead of calling ReceiveAsync individually for each header and the payload I am just grabbing up to a 1024 byte buffer chunk instead to save cpu usage.

However, I'm not sure what the best way of storing this data is? It has to be in order, and I want a separate thread to do the processing wit开发者_开发问答hout having any threading or performance issues.

Should I be looking at a memorystream or something along those lines?

Any ideas?


Don't store it. And don't use another thread to read it. I would use the same thread to deserialize it into something more usable. Then queue it in another thread and let the IOCP thread continue with it's processing.


Don't store it. Have the other thread read it when it needs it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号