OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 15 matching lines...) Expand all Loading... |
26 #define WebThread_h | 26 #define WebThread_h |
27 | 27 |
28 #include "WebCommon.h" | 28 #include "WebCommon.h" |
29 #include <stdint.h> | 29 #include <stdint.h> |
30 | 30 |
31 #ifdef INSIDE_BLINK | 31 #ifdef INSIDE_BLINK |
32 #include "wtf/Functional.h" | 32 #include "wtf/Functional.h" |
33 #endif | 33 #endif |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
| 36 class WebScheduler; |
36 class WebTraceLocation; | 37 class WebTraceLocation; |
37 | 38 |
38 // Always an integer value. | 39 // Always an integer value. |
39 typedef uintptr_t PlatformThreadId; | 40 typedef uintptr_t PlatformThreadId; |
40 | 41 |
41 // Provides an interface to an embedder-defined thread implementation. | 42 // Provides an interface to an embedder-defined thread implementation. |
42 // | 43 // |
43 // Deleting the thread blocks until all pending, non-delayed tasks have been | 44 // Deleting the thread blocks until all pending, non-delayed tasks have been |
44 // run. | 45 // run. |
45 class BLINK_PLATFORM_EXPORT WebThread { | 46 class BLINK_PLATFORM_EXPORT WebThread { |
(...skipping 24 matching lines...) Expand all Loading... |
70 // thread. | 71 // thread. |
71 virtual void postTask(const WebTraceLocation&, Task*) = 0; | 72 virtual void postTask(const WebTraceLocation&, Task*) = 0; |
72 virtual void postDelayedTask(const WebTraceLocation&, Task*, long long delay
Ms) = 0; | 73 virtual void postDelayedTask(const WebTraceLocation&, Task*, long long delay
Ms) = 0; |
73 | 74 |
74 virtual bool isCurrentThread() const = 0; | 75 virtual bool isCurrentThread() const = 0; |
75 virtual PlatformThreadId threadId() const { return 0; } | 76 virtual PlatformThreadId threadId() const { return 0; } |
76 | 77 |
77 virtual void addTaskObserver(TaskObserver*) { } | 78 virtual void addTaskObserver(TaskObserver*) { } |
78 virtual void removeTaskObserver(TaskObserver*) { } | 79 virtual void removeTaskObserver(TaskObserver*) { } |
79 | 80 |
| 81 // Returns the scheduler associated with the thread. |
| 82 virtual WebScheduler* scheduler() const = 0; |
| 83 |
80 // enterRunLoop() processes tasks posted to this WebThread. This call does n
ot return until some task calls exitRunLoop(). | 84 // enterRunLoop() processes tasks posted to this WebThread. This call does n
ot return until some task calls exitRunLoop(). |
81 // WebThread does not support nesting, meaning that once the run loop is ent
ered for a given WebThread it is not valid to | 85 // WebThread does not support nesting, meaning that once the run loop is ent
ered for a given WebThread it is not valid to |
82 // call enterRunLoop() again. | 86 // call enterRunLoop() again. |
83 virtual void enterRunLoop() = 0; | 87 virtual void enterRunLoop() = 0; |
84 | 88 |
85 // exitRunLoop() runs tasks until there are no tasks available to run, then
returns control to the caller of enterRunLoop(). | 89 // exitRunLoop() runs tasks until there are no tasks available to run, then
returns control to the caller of enterRunLoop(). |
86 // Must be called when the WebThread is running. | 90 // Must be called when the WebThread is running. |
87 virtual void exitRunLoop() = 0; | 91 virtual void exitRunLoop() = 0; |
88 | 92 |
89 virtual ~WebThread() { } | 93 virtual ~WebThread() { } |
90 | 94 |
91 #ifdef INSIDE_BLINK | 95 #ifdef INSIDE_BLINK |
92 // Helpers for posting bound functions as tasks. | 96 // Helpers for posting bound functions as tasks. |
93 void postTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>); | 97 void postTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>); |
94 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>,
long long delayMs); | 98 void postDelayedTask(const WebTraceLocation&, PassOwnPtr<Function<void()>>,
long long delayMs); |
95 #endif | 99 #endif |
96 }; | 100 }; |
97 | 101 |
98 } // namespace blink | 102 } // namespace blink |
99 | 103 |
100 #endif | 104 #endif |
OLD | NEW |