Re: [Cppcms-users] Synchronous app calls io_service.post() and blocks itself
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2014-03-18 10:57:44
|
> > Such hand made "cache" seems to be unable to fit my case. I > need to use > booster::aio::io_service as a synchronizer, like a mutex, to > > *sequentially* execute cppdb operations and manipulate > in-memory data. One VERY important point to alarm you. There is ONE even loop that handles LOTS of operations: incoming connections, uploads, transfers, request parsing, etc. It MUST not be blocked. As it basically blocks the entire CppCMS service from doing its job. If you call some heavy query to cppdb FROM the event loop or async app. You'll block the entire application. It is bad idea to abuse the even loop for such a purpose. Any operations in the async application or event loop must be as fast as possible and what is important - never block. If you run for example an SQL query that access the disk you may delay your entire cppcms application up to 6ms required for a physical disk to seek to the non-cached data. If you need to perform blocking/heavy operation by the async-app, inside event loop - post it to the thread pool and get the results "posted" back. If you want some "job queue" for sequential execution you'll probably want to create some additional execution queue, you may create your own booster::aio::io_service and run it in its own thread that would act like a dispatch queue (although it is most likely overkill) Or write your own simple job queue (which is quite a textbook tasks) Artyom |