Re: [Cppcms-users] async_flush_output and multipart/x_mixed_replace
Brought to you by:
artyom-beilis
From: Tobias R. <rei...@go...> - 2012-02-07 12:45:54
|
Artyom Beilis <artyomtnk@...> writes: > You are mixing calls from the boost::thread and the mail event loop thread and you should not. > Slightly changed example that works (without boost::thread) Since the context is not thread safe, this makes sense. However, I already tried your version without boost::thread and service::post in the first place. That's why I left the two corresponding lines in my code as comments: [...] //flush_output(); <--- tried this already service().post(boost::bind(&Application::flush_output, ...); [...] //compute_thread(); <--- tried this already thread_ = boost::thread(boost::bind(&Application::compute_thread, ...); [...] Since you say it works this way, there must be something else which is different. Could it have something to do with my web server or my browser? I'm using nginx and Firefox, but tried Chrome as well. I'm not caching anything on purpose. I even tried to send bigger packages each time to prevent some lazy sending mechanisms. > Read this: > > http://cppcms.com/wikipp/en/page/thread_safety "[...] If asynchronous application or any other object that runs in the event wants to execute some long running, blocking or heavy operation, it may do it by submitting an execution handler to the thread pool. [...]" As I understand this, there's the Event Loop for asynchronous operations and there's another Thread Pool for synchronous operations. In my case I have a heavy computation, which I should send via service::post (is that right?) to the Thread Pool. On the other side, I'd like to send back some progress or intermediate computation results, which I can do only by using context::async_flush_output, which is an asynchronous operation and thus part of the Event Loop. So, is it possible at all to call asynchronous operations from synchronous threads? Anyway, thank you very much for your time, Artyom. Best regards, Tobias |