Line data Source code
1 : /*
2 : * If not stated otherwise in this file or this component's LICENSE file the
3 : * following copyright and licenses apply:
4 : *
5 : * Copyright 2022 Sky UK
6 : *
7 : * Licensed under the Apache License, Version 2.0 (the "License");
8 : * you may not use this file except in compliance with the License.
9 : * You may obtain a copy of the License at
10 : *
11 : * http://www.apache.org/licenses/LICENSE-2.0
12 : *
13 : * Unless required by applicable law or agreed to in writing, software
14 : * distributed under the License is distributed on an "AS IS" BASIS,
15 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 : * See the License for the specific language governing permissions and
17 : * limitations under the License.
18 : */
19 :
20 : #ifndef FIREBOLT_RIALTO_IPC_I_BLOCKING_CLOSURE_H_
21 : #define FIREBOLT_RIALTO_IPC_I_BLOCKING_CLOSURE_H_
22 :
23 : #include "IIpcChannel.h"
24 : #include <memory>
25 :
26 : namespace firebolt::rialto::ipc
27 : {
28 : class IBlockingClosure;
29 :
30 : class IBlockingClosureFactory
31 : {
32 : public:
33 17 : IBlockingClosureFactory() = default;
34 17 : virtual ~IBlockingClosureFactory() = default;
35 :
36 : /**
37 : * @brief Create a IBlockingClosureFactory instance.
38 : *
39 : * @retval the factory instance or null on error.
40 : */
41 : static std::shared_ptr<IBlockingClosureFactory> createFactory();
42 :
43 : /**
44 : * @brief Creates a polling IBlockingClosure object.
45 : * Pump the event loop from within the wait() method.
46 : *
47 : * @param[in] ipcChannel : The ipc channel to wait on.
48 : *
49 : * @retval the protobuf controller instance or null on error.
50 : */
51 : virtual std::shared_ptr<IBlockingClosure>
52 : createBlockingClosurePoll(std::shared_ptr<::firebolt::rialto::ipc::IChannel> ipcChannel) = 0;
53 :
54 : /**
55 : * @brief Creates a semaphore IBlockingClosure object.
56 : * Do not pump the event loop from within the wait() method.
57 : *
58 : * @retval the protobuf controller instance or null on error.
59 : */
60 : virtual std::shared_ptr<IBlockingClosure> createBlockingClosureSemaphore() = 0;
61 : };
62 :
63 : class IBlockingClosure : public google::protobuf::Closure
64 : {
65 : public:
66 396 : IBlockingClosure() = default;
67 396 : virtual ~IBlockingClosure() = default;
68 :
69 : IBlockingClosure(const IBlockingClosure &) = delete;
70 : IBlockingClosure &operator=(const IBlockingClosure &) = delete;
71 : IBlockingClosure(IBlockingClosure &&) = delete;
72 : IBlockingClosure &operator=(IBlockingClosure &&) = delete;
73 :
74 : /**
75 : * @brief Wait for the response.
76 : */
77 : virtual void wait() = 0;
78 : };
79 :
80 : }; // namespace firebolt::rialto::ipc
81 :
82 : #endif // FIREBOLT_RIALTO_IPC_I_BLOCKING_CLOSURE_H_
|