OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ | 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ |
6 #define MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ | 6 #define MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ |
7 | 7 |
8 #include <assert.h> | 8 #include <assert.h> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 void swap(Handle& other) { | 167 void swap(Handle& other) { |
168 MojoHandle temp = value_; | 168 MojoHandle temp = value_; |
169 value_ = other.value_; | 169 value_ = other.value_; |
170 other.value_ = temp; | 170 other.value_ = temp; |
171 } | 171 } |
172 | 172 |
173 bool is_valid() const { | 173 bool is_valid() const { |
174 return value_ != kInvalidHandleValue; | 174 return value_ != kInvalidHandleValue; |
175 } | 175 } |
176 | 176 |
177 MojoHandle value() const { return value_; } | 177 const MojoHandle& value() const { return value_; } |
178 MojoHandle* mutable_value() { return &value_; } | 178 MojoHandle* mutable_value() { return &value_; } |
179 void set_value(MojoHandle value) { value_ = value; } | 179 void set_value(MojoHandle value) { value_ = value; } |
180 | 180 |
181 private: | 181 private: |
182 MojoHandle value_; | 182 MojoHandle value_; |
183 | 183 |
184 // Copying and assignment allowed. | 184 // Copying and assignment allowed. |
185 }; | 185 }; |
186 | 186 |
187 // Should have zero overhead. | 187 // Should have zero overhead. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 // Strict weak ordering, so that |Handle|s can be used as keys in |std::map|s, | 239 // Strict weak ordering, so that |Handle|s can be used as keys in |std::map|s, |
240 // etc. | 240 // etc. |
241 inline bool operator<(const Handle& a, const Handle& b) { | 241 inline bool operator<(const Handle& a, const Handle& b) { |
242 return a.value() < b.value(); | 242 return a.value() < b.value(); |
243 } | 243 } |
244 | 244 |
245 } // namespace mojo | 245 } // namespace mojo |
246 | 246 |
247 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ | 247 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ |
OLD | NEW |