Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sync_fence.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: Kevin DuBois <kevin.dubois@canonical.com>
17  */
18 #ifndef MIR_GRAPHICS_ANDROID_SYNC_FENCE_H_
19 #define MIR_GRAPHICS_ANDROID_SYNC_FENCE_H_
20 
22 #include <memory>
23 
24 namespace mir
25 {
26 namespace graphics
27 {
28 namespace android
29 {
30 
31 class SyncFileOps
32 {
33 public:
34  virtual ~SyncFileOps() = default;
35  virtual int ioctl(int, int, void*) = 0;
36  virtual int dup(int) = 0;
37  virtual int close(int) = 0;
38 };
39 
40 class RealSyncFileOps : public SyncFileOps
41 {
42 public:
43  int ioctl(int fd, int req, void* dat);
44  int dup(int fd);
45  int close(int fd);
46 };
47 
48 class SyncFence : public Fence
49 {
50 public:
51  SyncFence(std::shared_ptr<SyncFileOps> const&, int fd);
52  ~SyncFence() noexcept;
53 
54  void wait();
55  void merge_with(NativeFence& merge_fd);
56  NativeFence copy_native_handle() const;
57 
58 private:
59  SyncFence(SyncFence const&) = delete;
60  SyncFence& operator=(SyncFence const&) = delete;
61 
62  int fence_fd;
63  std::shared_ptr<SyncFileOps> const ops;
64 
65  int const infinite_timeout = -1;
66 };
67 
68 }
69 }
70 }
71 #endif /* MIR_GRAPHICS_ANDROID_SYNC_FENCE_H_ */

Copyright © 2012,2013 Canonical Ltd.
Generated on Wed Oct 30 18:52:19 UTC 2013