Re: [Cppcms-users] questions about chat example code
Brought to you by:
artyom-beilis
|
From: CN <cn...@fa...> - 2013-11-23 04:16:09
|
Thank you for your patience explaining all my questions! Here I have one minor feedback regarding wording. Excerpt from [1]http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime follows: "asynchronous applications are designed to handle multiple connections simultaneously, and thus instead of being called in the thread pool per each request, they run exclusively in the main [2]CppCMS Event Loop" Since asynchronous applications run in main thread and are event driven, shouldn't the word "simultaneously" be written as "sequentially" instead? Because asynchronous applications do not accept and process requests concurrently, requests must wait in line for processing. Asynchronous applications run in main thread and thus can never handle multiple connections simultaneously. They handle one connection at a time. If I do not understand this framework correctly, corrections are welcome and appreciated! Regards, CN On Fri, Nov 22, 2013, at 10:02 PM, Artyom Beilis wrote: (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: [3]http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop [4]http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime [5]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 -- [6]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. [7]http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg .clktrk _______________________________________________ Cppcms-users mailing list [8]Cpp...@li... [9]https://lists.sourceforge.net/lists/listinfo/cppcms-users ----------------------------------------------------------------------- ------- 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. [10]http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ost g.clktrk _______________________________________________ Cppcms-users mailing list [11]Cpp...@li... [12]https://lists.sourceforge.net/lists/listinfo/cppcms-users References 1. http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime 2. http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop 3. http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop 4. http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime 5. http://cppcms.com/wikipp/en/page/thread_safety 6. http://www.fastmail.fm/ 7. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk 8. mailto:Cpp...@li... 9. https://lists.sourceforge.net/lists/listinfo/cppcms-users 10. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk 11. mailto:Cpp...@li... 12. https://lists.sourceforge.net/lists/listinfo/cppcms-users -- http://www.fastmail.fm - A no graphics, no pop-ups email service |