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

Side by Side Diff: ppapi/cpp/message_loop.h

Issue 15004017: Clean up formatting to simplify post-Doxygen processing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Shortened description of file. Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/c/ppb_message_loop.h ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 PPAPI_CPP_MESSAGE_LOOP_H_ 5 #ifndef PPAPI_CPP_MESSAGE_LOOP_H_
6 #define PPAPI_CPP_MESSAGE_LOOP_H_ 6 #define PPAPI_CPP_MESSAGE_LOOP_H_
7 7
8 #include "ppapi/cpp/resource.h" 8 #include "ppapi/cpp/resource.h"
9 9
10 /// @file
11 /// This file defines the PPB_MessageLoop API.
12
10 namespace pp { 13 namespace pp {
11 14
12 class CompletionCallback; 15 class CompletionCallback;
13 class InstanceHandle; 16 class InstanceHandle;
14 17
15 /// A message loop allows PPAPI calls to be issued on a thread. You may not 18 /// A message loop allows PPAPI calls to be issued on a thread. You may not
16 /// issue any API calls on a thread without creating a message loop. It also 19 /// issue any API calls on a thread without creating a message loop. It also
17 /// allows you to post work to the message loop for a thread. 20 /// allows you to post work to the message loop for a thread.
18 /// 21 ///
19 /// To process work posted to the message loop, as well as completion callbacks 22 /// To process work posted to the message loop, as well as completion callbacks
(...skipping 12 matching lines...) Expand all
32 /// - Create the thread yourself (using pthreads). 35 /// - Create the thread yourself (using pthreads).
33 /// - Create the message loop resource. 36 /// - Create the message loop resource.
34 /// - Pass the message loop resource to your thread's main function. 37 /// - Pass the message loop resource to your thread's main function.
35 /// - Call PostWork() on the message loop to run functions on the thread. 38 /// - Call PostWork() on the message loop to run functions on the thread.
36 /// 39 ///
37 /// From the background thread's main function: 40 /// From the background thread's main function:
38 /// - Call AttachToCurrentThread() with the message loop resource. 41 /// - Call AttachToCurrentThread() with the message loop resource.
39 /// - Call Run() with the message loop resource. 42 /// - Call Run() with the message loop resource.
40 /// 43 ///
41 /// Your callbacks should look like this: 44 /// Your callbacks should look like this:
42 /// void DoMyWork(void* user_data, int32_t status) { 45 /// @code
43 /// if (status != PP_OK) { 46 /// void DoMyWork(void* user_data, int32_t status) {
44 /// Cleanup(); // e.g. free user_data. 47 /// if (status != PP_OK) {
45 /// return; 48 /// Cleanup(); // e.g. free user_data.
46 /// } 49 /// return;
47 /// ... do your work... 50 /// }
48 /// } 51 /// ... do your work...
52 /// }
53 /// @endcode
49 /// For a C++ example, see ppapi/utility/threading/simple_thread.h 54 /// For a C++ example, see ppapi/utility/threading/simple_thread.h
50 /// 55 ///
51 /// (You can also create the message loop resource on the background thread, 56 /// (You can also create the message loop resource on the background thread,
52 /// but then the main thread will have no reference to it should you want to 57 /// but then the main thread will have no reference to it should you want to
53 /// call PostWork()). 58 /// call PostWork()).
54 /// 59 ///
55 /// 60 ///
56 /// THREAD HANDLING 61 /// THREAD HANDLING
57 /// 62 ///
58 /// The main thread has an implicitly created message loop. The main thread is 63 /// The main thread has an implicitly created message loop. The main thread is
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 /// 114 ///
110 /// If you post a callback to a message loop that's been destroyed, or to an 115 /// If you post a callback to a message loop that's been destroyed, or to an
111 /// invalid message loop, PostWork will return an error and will not run the 116 /// invalid message loop, PostWork will return an error and will not run the
112 /// callback. This is true even for callbacks with the "required" flag set, 117 /// callback. This is true even for callbacks with the "required" flag set,
113 /// since the system may not even know what thread to issue the error callback 118 /// since the system may not even know what thread to issue the error callback
114 /// on. 119 /// on.
115 /// 120 ///
116 /// Therefore, you should check for errors from PostWork and destroy any 121 /// Therefore, you should check for errors from PostWork and destroy any
117 /// associated memory to avoid leaks. If you're using the C++ 122 /// associated memory to avoid leaks. If you're using the C++
118 /// CompletionCallbackFactory, use the following pattern: 123 /// CompletionCallbackFactory, use the following pattern:
119 /// 124 /// @code
120 /// pp::CompletionCallback callback = factory_.NewOptionalCallback(...); 125 /// pp::CompletionCallback callback = factory_.NewOptionalCallback(...);
121 /// int32_t result = message_loop.PostWork(callback); 126 /// int32_t result = message_loop.PostWork(callback);
122 /// if (result != PP_OK) 127 /// if (result != PP_OK)
123 /// callback.Run(result); 128 /// callback.Run(result);
124 /// 129 /// @endcode
125 /// This will run the callback with an error value, and assumes that the 130 /// This will run the callback with an error value, and assumes that the
126 /// implementation of your callback checks the "result" argument and returns 131 /// implementation of your callback checks the "result" argument and returns
127 /// immediately on error. 132 /// immediately on error.
128 class MessageLoop : public Resource { 133 class MessageLoop : public Resource {
129 public: 134 public:
130 /// Creates an is_null() MessageLoop resource. 135 /// Creates an is_null() MessageLoop resource.
131 MessageLoop(); 136 MessageLoop();
132 137
133 /// Creates a message loop associated with the given instance. The resource 138 /// Creates a message loop associated with the given instance. The resource
134 /// will be is_null() on failure. 139 /// will be is_null() on failure.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 /// - PP_ERROR_BADRESOURCE: The message loop was invalid. 259 /// - PP_ERROR_BADRESOURCE: The message loop was invalid.
255 /// - PP_ERROR_WRONG_THREAD: You are attempting to quit the main thread. 260 /// - PP_ERROR_WRONG_THREAD: You are attempting to quit the main thread.
256 /// The main thread's message loop is managed by the system and can't be 261 /// The main thread's message loop is managed by the system and can't be
257 /// quit. 262 /// quit.
258 int32_t PostQuit(bool should_destroy); 263 int32_t PostQuit(bool should_destroy);
259 }; 264 };
260 265
261 } // namespace pp 266 } // namespace pp
262 267
263 #endif // PPAPI_CPP_MESSAGE_LOOP_H_ 268 #endif // PPAPI_CPP_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « ppapi/c/ppb_message_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698