Re: [Cppcms-users] 100% cpu usage
Brought to you by:
artyom-beilis
|
From: <ele...@ex...> - 2013-08-02 06:05:12
|
Marcel,
Here is an example how you could design your asynchronous application
void nonblocking_function1()
{
// release_context() is the key
booster::shared_ptr<cppcms::http::context> ctx = release_context();
connections_.insert(ctx);
}
void nonblocking_function2()
{
srv_.thread_pool().post([=]() {
//do some heavy work like sql select
cppdb::result r = ....;
for(auto conn : connections_) {
// write out response to clients directly or add to a // queue
}
})
}
Depending on what you need to do, this might not work for you.
Artyom,
Is cppcms::http::response and cppcms::http::context thread safe?
I'm trying to decide, in the design of my app, whether I should be writing
to response().out() from the thread pool or whether I should be queuing
messages and sending them out from a single thread.
Cheers,
Petr
|