Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: mojo/public/cpp/system/handle.h

Issue 385983008: Mojo + NaCl prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: FinalEdits Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/c/system/tests/core_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 // Should have zero overhead. 187 // Should have zero overhead.
188 MOJO_COMPILE_ASSERT(sizeof(Handle) == sizeof(MojoHandle), 188 MOJO_COMPILE_ASSERT(sizeof(Handle) == sizeof(MojoHandle),
189 bad_size_for_cpp_Handle); 189 bad_size_for_cpp_Handle);
190 190
191 // The scoper should also impose no more overhead. 191 // The scoper should also impose no more overhead.
192 typedef ScopedHandleBase<Handle> ScopedHandle; 192 typedef ScopedHandleBase<Handle> ScopedHandle;
193 MOJO_COMPILE_ASSERT(sizeof(ScopedHandle) == sizeof(Handle), 193 MOJO_COMPILE_ASSERT(sizeof(ScopedHandle) == sizeof(Handle),
194 bad_size_for_cpp_ScopedHandle); 194 bad_size_for_cpp_ScopedHandle);
195 195
196 inline MojoResult Wait(const Handle& handle, 196 inline MojoResult Wait(Handle handle,
197 MojoHandleSignals signals, 197 MojoHandleSignals signals,
198 MojoDeadline deadline) { 198 MojoDeadline deadline) {
199 return MojoWait(handle.value(), signals, deadline); 199 return MojoWait(handle.value(), signals, deadline);
200 } 200 }
201 201
202 // |HandleVectorType| and |FlagsVectorType| should be similar enough to 202 // |HandleVectorType| and |FlagsVectorType| should be similar enough to
203 // |std::vector<Handle>| and |std::vector<MojoHandleSignals>|, respectively: 203 // |std::vector<Handle>| and |std::vector<MojoHandleSignals>|, respectively:
204 // - They should have a (const) |size()| method that returns an unsigned type. 204 // - They should have a (const) |size()| method that returns an unsigned type.
205 // - They must provide contiguous storage, with access via (const) reference to 205 // - They must provide contiguous storage, with access via (const) reference to
206 // that storage provided by a (const) |operator[]()| (by reference). 206 // that storage provided by a (const) |operator[]()| (by reference).
(...skipping 23 matching lines...) Expand all
230 // goes out of scope. 230 // goes out of scope.
231 template <class HandleType> 231 template <class HandleType>
232 inline void Close(ScopedHandleBase<HandleType> /*handle*/) {} 232 inline void Close(ScopedHandleBase<HandleType> /*handle*/) {}
233 233
234 // Most users should typically use |Close()| (above) instead. 234 // Most users should typically use |Close()| (above) instead.
235 inline MojoResult CloseRaw(Handle handle) { 235 inline MojoResult CloseRaw(Handle handle) {
236 return MojoClose(handle.value()); 236 return MojoClose(handle.value());
237 } 237 }
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 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(); 241 return a.value() < b.value();
243 } 242 }
244 243
245 } // namespace mojo 244 } // namespace mojo
246 245
247 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_ 246 #endif // MOJO_PUBLIC_CPP_SYSTEM_HANDLE_H_
OLDNEW
« no previous file with comments | « mojo/public/c/system/tests/core_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698