Re: [Cppcms-users] questions about chat example code
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2013-11-22 14:02:38
|
(1) It is not a recursive call, the error: is function that eventually calls read_data. It is callback/lambda expression it is not collected on the stacl (2) The client can't "reset connection" between these calls. The event of "connection reset" is detected in the event loop. It is not "multi-threading" it is event driven programming. The reset connection can be called only once we exit this code snippet. (3) As I mentioned before it is not multithreaded program. Async-application run in the thread of the event loop. I suggest read following sections: http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime http://cppcms.com/wikipp/en/page/thread_safety Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ On Wednesday, November 20, 2013 3:04 PM, CN <cn...@fa...> wrote: (1) ~/examples/chat/the_chat.html: >Lines 30 and 34 recursively call read_data(). Will these recursive calls >eventually eat up stack memory? If they will, how to improve the code? > >~/examples/chat/chat.cpp: > >(2) Line 64: >waiters_.insert(); >context->async_on_peer_reset() > >If the client resets connection between the above two calls, will it >cause memory leak (although the leak is not serious because broadcast() >will call waiters_.clear() eventually)? If it will, does swapping the >orders of these two lines help? > >context->async_on_peer_reset() >waiters_.insert(); > > > >(3) waiters_ manipulates its elements in get(), remove_context(), and >broadcast(). Do we need to implement lock mechanism on waiters_ to >ensure the code thread safe? If we do, how? > >I would appreciate your understanding that I am absolutely not finding >fault with the example code. Rather, I am trying to learn as many as I >can from it. > >Regards, >CN > >-- >http://www.fastmail.fm - The way an email service should be > > >------------------------------------------------------------------------------ >Shape the Mobile Experience: Free Subscription >Software experts and developers: Be at the forefront of tech innovation. >Intel(R) Software Adrenaline delivers strategic insight and game-changing >conversations that shape the rapidly evolving mobile landscape. Sign up now. >http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |