Re: [Cppcms-users] How to fullfill ajax-call from different thread?
Brought to you by:
artyom-beilis
From: Artyom B. <art...@gm...> - 2016-02-16 07:02:33
|
> Taking the json_rpc_chat example as a starting point, is it possible to > respond to get() from another thread? Let me elaborate a bit on that. > > In the chat example the get activates a callback that is called by a post > from the browser via the broadcast method. Is it possible to let this > callback be called by a different server-thread that is performing a task > and comes back with the result to be returned to the original get activated > by the browser? > > To put it differently, is it possible to interact with the json_rpc_server > and fullfill callbacks from outside? > > Reason for asking is that I'm using ajax-calls to perform tasks on the > server but I do not want the browser to hang up on it while waiting for the > result. > > Kind regards, > Eric > To be honest I don't clearly understand what are you trying to do. You have two types of applications: 1. Synchronous - running in threads and returning result immediately 2. Asynchronous - running in a single event loop - that can postpone the response or keep long running open connections if needed. You can "send" messages from synchronous apps (or what ever thread) to asynchronous apps by posting callbacks to the main event loop - i.e. service().post(some_function) such that this "some_function" would be executed in the event loop and can interact with the async apps. So for example you can have a generic thread that posts every minute a message to the chat from some thread using this callback method. Artyom > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |