[Cppcms-users] questions about chat example code
Brought to you by:
artyom-beilis
|
From: CN <cn...@fa...> - 2013-11-20 13:04:00
|
(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 |