Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
android_input_receiver_thread.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
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.
12  *
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/>.
15  *
16  * Authored by: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 #ifndef MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_THREAD_H_
20 #define MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_THREAD_H_
21 
23 
24 #include "mir_toolkit/event.h"
25 
26 #include <functional>
27 #include <memory>
28 #include <atomic>
29 #include <thread>
30 
31 namespace mir
32 {
33 namespace input
34 {
35 namespace receiver
36 {
37 namespace android
38 {
39 class InputReceiver;
40 
43 {
44 public:
45  InputReceiverThread(std::shared_ptr<InputReceiver> const& receiver,
46  std::function<void(MirEvent*)> const& event_handling_callback);
47  virtual ~InputReceiverThread();
48 
49  void start();
50  void stop();
51  void join();
52 
53 protected:
56 
57 private:
58  std::shared_ptr<InputReceiver> const receiver;
59  std::function<void(MirEvent*)> const handler;
60 
61  void thread_loop();
62  std::atomic<bool> running;
63  std::thread thread;
64 };
65 
66 }
67 }
68 }
69 } // namespace mir
70 
71 #endif // MIR_INPUT_RECEIVER_ANDROID_INPUT_RECEIVER_THREAD_H_
All things Mir.
Definition: aging_buffer.h:24
Responsible for polling an InputReceiver to read and dispatch events when appropriate.
Definition: android_input_receiver_thread.h:42
InputReceiverThread & operator=(const InputReceiverThread &)=delete
virtual ~InputReceiverThread()
Definition: android_input_receiver_thread.cpp:34
void start()
Definition: android_input_receiver_thread.cpp:42
Definition: input_receiver_thread.h:29
Definition: android_input_receiver.h:32
Definition: event.h:227
void stop()
Definition: android_input_receiver_thread.cpp:48
void join()
Definition: android_input_receiver_thread.cpp:54

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Oct 10 14:07:14 UTC 2014