Thread: [Cppcms-users] Document regarding input content filtering
Brought to you by:
artyom-beilis
From: CN <cn...@fa...> - 2016-04-12 16:13:33
|
Greetings, I can imagine we might be able to put something like this my_cppcms_service.applications_pool().mount(cppcms::create_pool<myfilter>(),cppcms::mount_point("(.*)",1),cppcms::app::asynchronous | cppcms::app::content_filter); in int main(int,char**){ //here } , but I have trouble figuring out how to pass booster::weak_ptr<cppcms::application_specific_pool> or booster::shared_ptr<cppcms::application_specific_pool> as the argument to the constructor of myfilter: myfilter(cppcms::service &srv, weak_pool_ptr ptr): cppcms::application(srv), wpool_(ptr) { .. } I will much appreciate if some kind soul will provide me an example in int main(int,char**){ //here } Best regards, CN -- http://www.fastmail.com - Accessible with your email software or over the web |
From: Artyom B. <art...@gm...> - 2016-04-12 19:37:26
|
Currently there is private member function application::get_pool() I can create a public version of one or make it public. I don't recall right now why I have made it private. The question is what are you trying to do, when do you need your own pool? i.e. I want to know the scenario you are trying to implement so I can adjust the API accordingly. Of course you can create some pool_proxy object that you pass to the constructor of your own application that keeps the reference to the pool. Something like that myfilter(cppcms::service &srv, booster::shared_ptr<weak_pool_ptr> ptr)... And than use it this way: booster::shared_ptr<weak_pool_ptr> proxy(new weak_pool_ptr()); shared_pool_ptr tmp = cppcms::create_pool<myfilter>(proxy), (*proxy) = tmp; srv.applications_pool().mount(tmp,...) Also it is quite ugly. Artyom On Tue, Apr 12, 2016 at 7:13 PM, CN <cn...@fa...> wrote: > Greetings, > > I can imagine we might be able to put something like this > > my_cppcms_service.applications_pool().mount(cppcms::create_pool<myfilter>(),cppcms::mount_point("(.*)",1),cppcms::app::asynchronous > | cppcms::app::content_filter); > > in > > int main(int,char**){ //here } > > , but I have trouble figuring out how to pass > booster::weak_ptr<cppcms::application_specific_pool> > or > booster::shared_ptr<cppcms::application_specific_pool> > as the argument to the constructor of myfilter: > > myfilter(cppcms::service &srv, weak_pool_ptr ptr): > cppcms::application(srv), > wpool_(ptr) > { > .. > } > > I will much appreciate if some kind soul will provide me an example in > int main(int,char**){ //here } > > Best regards, > CN > > -- > http://www.fastmail.com - Accessible with your email software > or over the web > > > ------------------------------------------------------------------------------ > Find and fix application performance issues faster with Applications Manager > Applications Manager provides deep performance insights into multiple tiers of > your business applications. It resolves application problems quickly and > reduces your MTTR. Get your free trial! > https://ad.doubleclick.net/ddm/clk/302982198;130105516;z > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: CN <cn...@fa...> - 2016-04-13 03:32:55
|
On Wed, Apr 13, 2016, at 03:37 AM, Artyom Beilis wrote: > Currently there is private member function application::get_pool() I > can create a public version of one or make it public. > I don't recall right now why I have made it private. > > The question is what are you trying to do, when do you need your own > pool? > i.e. I want to know the scenario you are trying to implement so I can > adjust the API accordingly. Oops! I wanted to include this URL in my original message but forgot to do so: http://cppcms.com/wikipp/en/page/cppcms_1_2_filtering Please refer to the tutorial illustrated in "Resubmitting Context". > > Of course you can create some pool_proxy object that you pass to the > constructor of your own application > that keeps the reference to the pool. > > Something like that > > myfilter(cppcms::service &srv, booster::shared_ptr<weak_pool_ptr> ptr)... > > And than use it this way: > > booster::shared_ptr<weak_pool_ptr> proxy(new weak_pool_ptr()); > shared_pool_ptr tmp = cppcms::create_pool<myfilter>(proxy), > (*proxy) = tmp; > srv.applications_pool().mount(tmp,...) > > Also it is quite ugly. It is difficult to read, indeed. I am trying very hard now to understand this example... Before we have a public application::get_pool(), maybe the last statement is supposed to look like this? srv.applications_pool().mount(tmp,proxy...) Thanks a lot! Best regards, CN -- http://www.fastmail.com - Faster than the air-speed velocity of an unladen european swallow |
From: CN <cn...@fa...> - 2016-04-13 04:51:09
|
On Wed, Apr 13, 2016, at 11:32 AM, CN wrote: > Before we have a public application::get_pool(), maybe the last > statement is supposed to look like this? > srv.applications_pool().mount(tmp,proxy...) Please ignore this incorrect part! Best regards, CN -- http://www.fastmail.com - Accessible with your email software or over the web |
From: CN <cn...@fa...> - 2016-04-13 08:18:45
|
On Wed, Apr 13, 2016, at 03:37 AM, Artyom Beilis wrote: > Currently there is private member function application::get_pool() I > can create a public version of one or make it public. > I don't recall right now why I have made it private. > I moved application::get_pool() from private to public just now and this much cleaner version than the orginal one http://cppcms.com/wikipp/en/page/cppcms_1_2_filtering compiles: void main(std::sting path) { if(!request().is_ready()) { // handle all filtering stuff } else { pool_ptr pool = get_pool().lock(); /* note here! */ if(pool) { shared_ptr<context> ctx = release_context(); // now this context goes to another // application to be run. ctx->submit_to_pool(pool,path); } } } Best regards, CN -- http://www.fastmail.com - Access all of your messages and folders wherever you are |
From: Artyom B. <art...@gm...> - 2016-04-13 10:24:16
|
Ok got your problem... See, resubmitting the context is to take a context from an application in one pool and move to another, for example to do filter in async application and move the context to sync application for processing. The idea is following: You create one pool - lets say synchronous and keep a week_ptr on it. Than you create a new asynchronous filtering pool and pass it to the filtering pool: shared_ptr processor = cppcms::create_pool<myprcessor>(); srv.applications_pool().mount(processor,...) weak_ptr weak_pool = processor; srv.applications_pool().mount(cppcms::create_pool<myfilter>(weak_pool),asynchronous|filter) So the weak reference to the pool is reference to another pool not my own pool. The code I shown is how to get __my own__ pool rather than another one because without a tutorial context you wanted to get your own pool. In general you don't resubmit context to yourself > pool_ptr pool = get_pool().lock(); /* note here! */ > if(pool) { > shared_ptr<context> ctx = release_context(); > // now this context goes to another > // application to be run. > ctx->submit_to_pool(pool,path); > > } Would create an infinite loop. So if you want the reference to the pool you need to keep one from the beginning. Artyom |
From: CN <cn...@fa...> - 2016-04-13 16:21:45
|
On Wed, Apr 13, 2016, at 06:24 PM, Artyom Beilis wrote: > Ok got your problem... > > See, resubmitting the context is to take a context from an application > in one pool and move to another, > for example to do filter in async application and move the context to > sync application for processing. > > The idea is following: > > You create one pool - lets say synchronous and keep a week_ptr on it. > Than you create a new asynchronous filtering pool and pass it to the > filtering pool: > > shared_ptr processor = cppcms::create_pool<myprcessor>(); > srv.applications_pool().mount(processor,...) > weak_ptr weak_pool = processor; > srv.applications_pool().mount(cppcms::create_pool<myfilter>(weak_pool),asynchronous|filter) > > So the weak reference to the pool is reference to another pool not my own > pool. > I think I finally have learned how to send asynchronous jobs to synchronously run in applications pool. Many thanks for your patience! Best regards, CN -- http://www.fastmail.com - A no graphics, no pop-ups email service |