You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by "Knick, Scott E CTR USARMY RCERT-EUR (US)" <sc...@mail.mil> on 2012/11/30 12:31:48 UTC

RE: Yielding service handler methods in C++ (UNCLASSIFIED)

Classification: UNCLASSIFIED
Caveats: FOUO

Good question on the C++ APIs... Seems like I also only see C++ generated code for writing the service implementation but not connecting to one.

-----Original Message-----
From: Amir Taaki [mailto:zgenjix@yahoo.com] 
Sent: Friday, November 30, 2012 12:30 PM
To: user@thrift.apache.org
Subject: Yielding service handler methods in C++

Hey,

I'd like to have my service handler make an async request and then return the result once it's ready.

Currently you have something like:

int32_t add(const int32_t n1, const int32_t n2) {
    int32_t result = do_something(n1, n2);

    return result;

}

I want to be able to do something like:

void add(Result& result, const int32_t n1, const int32_t n2) {
    // function call returns immediately

    do_something(result, n1, n2);
}

The operation 'add' is added to a stack, and then a worker thread picks it up, computes the result and finally gives it back to thrift so it can be sent to the client.

Otherwise I'd have to use futures and promises which isn't the best solution if thrift supports async natively.

BTW are there any libthrift C++ packages. I saw only Java and Python bindings so I was confused why the core library is missing.


Classification: UNCLASSIFIED
Caveats: FOUO