Re: [Cppcms-users] Communication between synchronous and asynchronous applications
Brought to you by:
artyom-beilis
|
From: CN <cn...@fa...> - 2013-11-23 06:00:39
|
Having contemplated for a while, I am trying to reply my first question as follows. Please correct me if I am wrong! The solution might be as simple as passing the reference of the asynchronous application object as a parameter to the synchronous application in interest like this: cppcms::service srv(argc,argv); booster::intrusive_ptr<chat> c=new chat(srv); srv.applications_pool().mount(cppcms::applications_factory<my_hello_world>(c)); service.applications_pool().mount(c); Regards, CN On Sat, Nov 23, 2013, at 11:02 AM, CN wrote: Applications my_hello_world and chat are mounted under different application tree branches, How does my_hello_world acquire the reference of chat instance? I'ts good to know that cppcms::service::post() is not required in such case! Nevertheless, an example code demonstrating the usage of cppcms::service::post() would be greatly appreciated - just in case I will need to call it some other day! Regards, CN On Fri, Nov 22, 2013, at 10:05 PM, Artyom Beilis wrote: Just create some thread safe object that can keep the data you need (i.e. member functions that access it protected with mutexes/rw-locks). Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ On Friday, November 22, 2013 8:12 AM, CN <cn...@fa...> wrote: Hello! Imagine I have both synchronous and asynchronous applications mounted: int main(int argc,char ** argv) { try { cppcms::service srv(argc,argv); srv.applications_pool().mount(cppcms::applications_factory<my_hello_wor ld>()); booster::intrusive_ptr<chat> c=new chat(srv); service.applications_pool().mount(c); srv.run(); } catch(std::exception const &e) { std::cerr<<e.what()<<std::endl; } } Assume that std::vector<cppcms::json::value> messages_; in [1]http://cppcms.com/wikipp/en/page/cppcms_1x_chat_json_rpc is public. If I understand the framework correctly, asynchronous applications run in main thread. Therefore, asynchronous applications are appropriate candidates to keep cross-application data, messages_ in our example, that is to be shared by synchronous applications. I would like to know how to access messages_ kept in chat application from my_hello_world. I have read both [2]http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop and [3]http://cppcms.com/cppcms_ref/latest/classcppcms_1_1service.html#a294 10e26d78c56c3f22389db5828cd0c but still have no idea how. Helps will be greatly appreciated. Regards, CN -- [4]http://www.fastmail.fm - Or how I learned to stop worrying and love email again ----------------------------------------------------------------------- ------- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. [5]http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg .clktrk _______________________________________________ Cppcms-users mailing list [6]Cpp...@li... [7]https://lists.sourceforge.net/lists/listinfo/cppcms-users ----------------------------------------------------------------------- ------- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. [8]http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg .clktrk _______________________________________________ Cppcms-users mailing list [9]Cpp...@li... [10]https://lists.sourceforge.net/lists/listinfo/cppcms-users -- http://www.fastmail.fm - Access all of your messages and folders wherever you are ----------------------------------------------------------------------- ------- Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. [11]http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ost g.clktrk _______________________________________________ Cppcms-users mailing list [12]Cpp...@li... [13]https://lists.sourceforge.net/lists/listinfo/cppcms-users References 1. http://cppcms.com/wikipp/en/page/cppcms_1x_chat_json_rpc 2. http://cppcms.com/wikipp/en/page/cppcms_1x_event_loop 3. http://cppcms.com/cppcms_ref/latest/classcppcms_1_1service.html#a29410e26d78c56c3f22389db5828cd0c 4. http://www.fastmail.fm/ 5. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk 6. mailto:Cpp...@li... 7. https://lists.sourceforge.net/lists/listinfo/cppcms-users 8. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk 9. mailto:Cpp...@li... 10. https://lists.sourceforge.net/lists/listinfo/cppcms-users 11. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk 12. mailto:Cpp...@li... 13. https://lists.sourceforge.net/lists/listinfo/cppcms-users -- http://www.fastmail.fm - One of many happy users: http://www.fastmail.fm/help/overview_quotes.html |