blob: abf5816191bb0ca691e9bd7d46a81e82436145e1 [file] [log] [blame]
David Reiss5ddabb82010-10-06 17:09:37 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef _THRIFT_TASYNCPROCESSOR_H_
21#define _THRIFT_TASYNCPROCESSOR_H_ 1
22
23#include <tr1/functional>
24#include <boost/shared_ptr.hpp>
25#include <protocol/TProtocol.h>
26#include <TProcessor.h>
27
28namespace apache { namespace thrift { namespace async {
29
30/**
31 * Async version of a TProcessor. It is not expected to complete by the time
32 * the call to process returns. Instead, it calls a cob to signal completion.
33 */
34class TAsyncProcessor {
35 public:
36 virtual ~TAsyncProcessor() {}
37
38 virtual void process(std::tr1::function<void(bool success)> _return,
39 boost::shared_ptr<protocol::TProtocol> in,
40 boost::shared_ptr<protocol::TProtocol> out) = 0;
41
42 void process(std::tr1::function<void(bool success)> _return,
43 boost::shared_ptr<apache::thrift::protocol::TProtocol> io) {
44 return process(_return, io, io);
45 }
46
47 protected:
48 TAsyncProcessor() {}
49};
50
51}}} // apache::thrift::async
52
53// XXX I'm lazy for now
54namespace apache { namespace thrift {
55using apache::thrift::async::TAsyncProcessor;
56}}
57
58#endif // #ifndef _THRIFT_TASYNCPROCESSOR_H_