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

Side by Side Diff: ppapi/c/ppb_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: Created 7 years, 7 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
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 5
6 /* From ppb_message_loop.idl modified Mon Apr 1 12:14:25 2013. */ 6 /* From ppb_message_loop.idl modified Thu May 9 14:59:57 2013. */
7 7
8 #ifndef PPAPI_C_PPB_MESSAGE_LOOP_H_ 8 #ifndef PPAPI_C_PPB_MESSAGE_LOOP_H_
9 #define PPAPI_C_PPB_MESSAGE_LOOP_H_ 9 #define PPAPI_C_PPB_MESSAGE_LOOP_H_
10 10
11 #include "ppapi/c/pp_bool.h" 11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_completion_callback.h" 12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_instance.h" 13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_macros.h" 14 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
16 #include "ppapi/c/pp_stdint.h" 16 #include "ppapi/c/pp_stdint.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 * - Create the thread yourself (using pthreads). 48 * - Create the thread yourself (using pthreads).
49 * - Create the message loop resource. 49 * - Create the message loop resource.
50 * - Pass the message loop resource to your thread's main function. 50 * - Pass the message loop resource to your thread's main function.
51 * - Call PostWork() on the message loop to run functions on the thread. 51 * - Call PostWork() on the message loop to run functions on the thread.
52 * 52 *
53 * From the background thread's main function: 53 * From the background thread's main function:
54 * - Call AttachToCurrentThread() with the message loop resource. 54 * - Call AttachToCurrentThread() with the message loop resource.
55 * - Call Run() with the message loop resource. 55 * - Call Run() with the message loop resource.
56 * 56 *
57 * Your callbacks should look like this: 57 * Your callbacks should look like this:
58 * @code 58 * @code
59 * void DoMyWork(void* user_data, int32_t status) { 59 * void DoMyWork(void* user_data, int32_t status) {
60 * if (status != PP_OK) { 60 * if (status != PP_OK) {
61 * Cleanup(); // e.g. free user_data. 61 * Cleanup(); // e.g. free user_data.
62 * return; 62 * return;
63 * } 63 * }
64 * ... do your work... 64 * ... do your work...
65 * } 65 * }
66 * @endcode 66 * @endcode
67 * For a C++ example, see ppapi/utility/threading/simple_thread.h 67 * For a C++ example, see ppapi/utility/threading/simple_thread.h
68 * 68 *
69 * (You can also create the message loop resource on the background thread, 69 * (You can also create the message loop resource on the background thread,
70 * but then the main thread will have no reference to it should you want to 70 * but then the main thread will have no reference to it should you want to
71 * call PostWork()). 71 * call PostWork()).
72 * 72 *
73 * 73 *
74 * THREAD HANDLING 74 * THREAD HANDLING
75 * 75 *
76 * The main thread has an implicitly created message loop. The main thread is 76 * 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
127 * 127 *
128 * If you post a callback to a message loop that's been destroyed, or to an 128 * If you post a callback to a message loop that's been destroyed, or to an
129 * invalid message loop, PostWork will return an error and will not run the 129 * invalid message loop, PostWork will return an error and will not run the
130 * callback. This is true even for callbacks with the "required" flag set, 130 * callback. This is true even for callbacks with the "required" flag set,
131 * since the system may not even know what thread to issue the error callback 131 * since the system may not even know what thread to issue the error callback
132 * on. 132 * on.
133 * 133 *
134 * Therefore, you should check for errors from PostWork and destroy any 134 * Therefore, you should check for errors from PostWork and destroy any
135 * associated memory to avoid leaks. If you're using the C++ 135 * associated memory to avoid leaks. If you're using the C++
136 * CompletionCallbackFactory, use the following pattern: 136 * CompletionCallbackFactory, use the following pattern:
137 * 137 * @code
138 * pp::CompletionCallback callback = factory_.NewOptionalCallback(...); 138 * pp::CompletionCallback callback = factory_.NewOptionalCallback(...);
139 * int32_t result = message_loop.PostWork(callback); 139 * int32_t result = message_loop.PostWork(callback);
140 * if (result != PP_OK) 140 * if (result != PP_OK)
141 * callback.Run(result); 141 * callback.Run(result);
142 * 142 * @endcode
143 * This will run the callback with an error value, and assumes that the 143 * This will run the callback with an error value, and assumes that the
144 * implementation of your callback checks the "result" argument and returns 144 * implementation of your callback checks the "result" argument and returns
145 * immediately on error. 145 * immediately on error.
146 */ 146 */
147 struct PPB_MessageLoop_1_0 { 147 struct PPB_MessageLoop_1_0 {
148 /** 148 /**
149 * Creates a message loop resource. 149 * Creates a message loop resource.
150 * 150 *
151 * This may be called from any thread. After your thread starts but before 151 * This may be called from any thread. After your thread starts but before
152 * issuing any other PPAPI calls on it, you must associate it with a message 152 * issuing any other PPAPI calls on it, you must associate it with a message
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 int32_t (*PostQuit)(PP_Resource message_loop, PP_Bool should_destroy); 282 int32_t (*PostQuit)(PP_Resource message_loop, PP_Bool should_destroy);
283 }; 283 };
284 284
285 typedef struct PPB_MessageLoop_1_0 PPB_MessageLoop; 285 typedef struct PPB_MessageLoop_1_0 PPB_MessageLoop;
286 /** 286 /**
287 * @} 287 * @}
288 */ 288 */
289 289
290 #endif /* PPAPI_C_PPB_MESSAGE_LOOP_H_ */ 290 #endif /* PPAPI_C_PPB_MESSAGE_LOOP_H_ */
291 291
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698