2 * Copyright © 2012 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Authored by: Alan Griffiths <alan@octopull.co.uk>
19 #ifndef ANBOX_RPC_PENDING_CALL_CACHE_
20 #define ANBOX_RPC_PENDING_CALL_CACHE_
30 } // namespace protobuf
39 } // namespace protobuf
41 class PendingCallCache {
45 void save_completion_details(
46 anbox::protobuf::rpc::Invocation const &invocation,
47 google::protobuf::MessageLite *response,
48 google::protobuf::Closure *complete);
49 void populate_message_for_result(
50 anbox::protobuf::rpc::Result &result,
51 std::function<void(google::protobuf::MessageLite *)> const &populator);
52 void complete_response(anbox::protobuf::rpc::Result &result);
53 void force_completion();
58 PendingCall(google::protobuf::MessageLite *response,
59 google::protobuf::Closure *target)
60 : response(response), complete(target) {}
62 PendingCall() : response(0), complete() {}
64 google::protobuf::MessageLite *response;
65 google::protobuf::Closure *complete;
68 std::mutex mutable mutex_;
69 std::map<int, PendingCall> pending_calls_;