~rpadovani/reminders-app/fixForReload

« back to all changes in this revision

Viewing changes to 3rdParty/libthrift/async/TAsyncProcessor.h

  • Committer: Michael Zanetti
  • Date: 2013-11-21 23:30:15 UTC
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: michael.zanetti@canonical.com-20131121233015-fnbjnzcb6chdtdzm
add libthrift, evernote-sdk and a Evernote qml plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
 
28
namespace 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
 */
 
34
 
 
35
class TEventServer; // forward declaration
 
36
 
 
37
class TAsyncProcessor {
 
38
 public:
 
39
  virtual ~TAsyncProcessor() {}
 
40
 
 
41
  virtual void process(std::tr1::function<void(bool success)> _return,
 
42
                       boost::shared_ptr<protocol::TProtocol> in,
 
43
                       boost::shared_ptr<protocol::TProtocol> out) = 0;
 
44
 
 
45
  void process(std::tr1::function<void(bool success)> _return,
 
46
               boost::shared_ptr<apache::thrift::protocol::TProtocol> io) {
 
47
    return process(_return, io, io);
 
48
  }
 
49
 
 
50
  boost::shared_ptr<TProcessorEventHandler> getEventHandler() {
 
51
    return eventHandler_;
 
52
  }
 
53
 
 
54
  void setEventHandler(boost::shared_ptr<TProcessorEventHandler> eventHandler) {
 
55
    eventHandler_ = eventHandler;
 
56
  }
 
57
 
 
58
  const TEventServer* getAsyncServer() {
 
59
    return asyncServer_;
 
60
  }
 
61
 protected:
 
62
  TAsyncProcessor() {}
 
63
 
 
64
  boost::shared_ptr<TProcessorEventHandler> eventHandler_;
 
65
  const TEventServer* asyncServer_;
 
66
 private:
 
67
  friend class TEventServer;
 
68
  void setAsyncServer(const TEventServer* server) {
 
69
    asyncServer_ = server;
 
70
  }
 
71
};
 
72
 
 
73
class TAsyncProcessorFactory {
 
74
 public:
 
75
  virtual ~TAsyncProcessorFactory() {}
 
76
 
 
77
  /**
 
78
   * Get the TAsyncProcessor to use for a particular connection.
 
79
   *
 
80
   * This method is always invoked in the same thread that the connection was
 
81
   * accepted on.  This generally means that this call does not need to be
 
82
   * thread safe, as it will always be invoked from a single thread.
 
83
   */
 
84
  virtual boost::shared_ptr<TAsyncProcessor> getProcessor(
 
85
      const TConnectionInfo& connInfo) = 0;
 
86
};
 
87
 
 
88
 
 
89
 
 
90
}}} // apache::thrift::async
 
91
 
 
92
// XXX I'm lazy for now
 
93
namespace apache { namespace thrift {
 
94
using apache::thrift::async::TAsyncProcessor;
 
95
}}
 
96
 
 
97
#endif // #ifndef _THRIFT_TASYNCPROCESSOR_H_