现插槽。*异步方法线程? [英] Are Socket.*Async methods threaded?

查看:129
本文介绍了现插槽。*异步方法线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在试图找出什么是尽量减少我在一个TCP主服务器使用的线程数量,以最大限度地提高性能的最佳方式。

I'm currently trying to figure what is the best way to minimize the amount of threads I use in a TCP master server, in order to maximize performance.

正如我已经读了很多最近与C#5.0新异步功能,异步并不一定意味着多线程。这可能意味着分离有限状态对象的小块,然后与其他业务处理,通过交替。不过,我不明白这到底是怎么在网络中完成,因为我基本上是等待输入(从客户端)。

As I've been reading a lot recently with the new async features of C# 5.0, asynchronous does not necessarily mean multithreaded. It could mean separated in smaller chunks of finite state objects, then processed alongside other operations, by alternating. However, I don't see how this could be done in networking, since I'm basically "waiting" for input (from the client).

所以,我不会用ReceiveAsync()为我所有的插座,它只是被创造和不断结束线程(假设它的确实的创建线程)。

Therefore, I wouldn't use ReceiveAsync() for all my sockets, it would just be creating and ending threads continuously (assuming it does create threads).

因此​​,我的问题是多还是少?什么架构的主服务器,而不采取每个连接有一个线程

Consequently, my question is more or less: what architecture can a master server take without having one "thread" per connection?

奖金冷静点边的问题:为什么有多个线程不好,考虑到其线程就是在你的处理核心数量的多少只是使机器假货多线程,就像任何其他异步方法将

Side question for bonus coolness points: Why is having multiple threads bad, considering that having an amount of threads that is over your amount of processing cores simply makes the machine "fake" multithreading, just like any other asynchronous method would?

推荐答案

好像 *异步方法使用IOCP(通过查看code与反射镜)

Seems like the *Async methods use IOCP (by looking at the code with Reflector).

这篇关于现插槽。*异步方法线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆