Long run thread

Aug 25, 2014 at 11:17 AM

I want to create a long task which would send "GET" requests to some api and other threads will parse the results, but only 1 "GET" request must be running.
I know how do it with basic threads, create 2 threads, 1st sending "get" requests and pushing return data to queue and 2nd deque from this queue.
But how can i do it with PPL?
Aug 26, 2014 at 3:54 PM
I think my question is the same as Miktor's - I want to use Casablanca (on Ubuntu Linux) for a REST client that includes long polling. At a certain point in the application, a GET is done, and it remains open on the server side. Multiple asynchronous responses would be sent during the life of the app.

As I'm new to Casablanca and PPL, I'm not sure how to structure things on the Casablanca/PPL side. Surely it must be possible with a package oriented toward asynch programming?

Thanks for any hints.

Aug 26, 2014 at 4:12 PM
I found one way.
Here is example of do_while loop with cancellation.
It can be adapted to our needs.
Also we have to create 2 tasks.
1st is the loop where we sending and receiving data synchronously and storing it in concurrent_queue for example.
In the 2nd we pop from queue receive data and do some stuff with it.
But in this implementation the 1st task should be replaces with std::thread because he always running.
I know that there is a Scheduler in ppl but i can't find how to run only 2 tasks (for example) of one type/group in time.

So i think i will impl. it with std::thread.
Aug 27, 2014 at 4:49 PM
Somewhat related, depending on what you want to accomplish, you also can create and specify your own custom scheduler for executing tasks. Then you can pass you schedule to create_task and .then continuations. See this discussion for more details.