multi-thread server with boost::asio or boost::thread?

Hello boost users, I'm currently working on a MMO game server and have been using the boost::asio to deal with sockets. For now i'm concerned with responsiveness and scalability, and have been thinking of two ways to achieve that. The first way would be multiple calls to io_service.run, each in a different thread, using the strand object to synchronize the callback handlers. The other way is to explicit use threads and locks with the boost::thread lib. So could you point me what would be the main differences (maybe advantages and disadvantages) between both ways? What way do you think is it better? I want to hear some opinions. Thanx in advance and best regards! -- Matheus Araújo Aguiar Computer Scientist matheus.pit@gmail.com

The first way would be multiple calls to io_service.run, each in a different thread, using the strand object to synchronize the callback handlers. The other way is to explicit use threads and locks with the boost::thread lib. So could you point me what would be the main differences (maybe advantages and disadvantages) between both ways? What way do you think is it better? I want to hear some opinions.
first way. Because it is natural. The second way is probably something that has sense for synchronous operations, but words "scalability" and "responsiveness" are often used with word "async".

Thanx for the reply Roman.
Well, for what i've understood, if i use the strand i'll have concurrent
callback handlers, but each handler will execute serially, is that right?
On Mon, Jun 1, 2009 at 4:09 PM, Roman Shmelev
The first way would be multiple calls to io_service.run, each in a different thread, using the strand object to synchronize the callback handlers. The other way is to explicit use threads and locks with the boost::thread lib. So could you point me what would be the main differences (maybe advantages and disadvantages) between both ways? What way do you think is it better? I want to hear some opinions.
first way. Because it is natural. The second way is probably something that has sense for synchronous operations, but words "scalability" and "responsiveness" are often used with word "async". _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Matheus Araújo Aguiar Computer Scientist matheus.pit@gmail.com

Well, for what i've understood, if i use the strand i'll have concurrent callback handlers, but each handler will execute serially, is that right?
sorry for late response) I suggest you reading the documentation. I can say something wrong, but documentation cannot. As I remember, tutorials enlight boost::strands theme. As I understand, using strands is like mutexes in concept - nothing really hard. http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/overview/core/stran...
participants (2)
-
Matheus Araújo Aguiar
-
Roman Shmelev