OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2013 Apple 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 16 matching lines...) Expand all Loading... |
27 */ | 27 */ |
28 | 28 |
29 #ifndef TaskSynchronizer_h | 29 #ifndef TaskSynchronizer_h |
30 #define TaskSynchronizer_h | 30 #define TaskSynchronizer_h |
31 | 31 |
32 #include "platform/PlatformExport.h" | 32 #include "platform/PlatformExport.h" |
33 #include "wtf/Noncopyable.h" | 33 #include "wtf/Noncopyable.h" |
34 #include "wtf/Threading.h" | 34 #include "wtf/Threading.h" |
35 #include "wtf/ThreadingPrimitives.h" | 35 #include "wtf/ThreadingPrimitives.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace blink { |
38 | 38 |
39 // TaskSynchronizer can be used to wait for task completion. | 39 // TaskSynchronizer can be used to wait for task completion. |
40 class PLATFORM_EXPORT TaskSynchronizer { | 40 class PLATFORM_EXPORT TaskSynchronizer { |
41 WTF_MAKE_NONCOPYABLE(TaskSynchronizer); | 41 WTF_MAKE_NONCOPYABLE(TaskSynchronizer); |
42 public: | 42 public: |
43 TaskSynchronizer(); | 43 TaskSynchronizer(); |
44 | 44 |
45 // Called from a thread that waits for the task completion. | 45 // Called from a thread that waits for the task completion. |
46 void waitForTaskCompletion(); | 46 void waitForTaskCompletion(); |
47 | 47 |
48 // Called from a thread that executes the task. | 48 // Called from a thread that executes the task. |
49 void taskCompleted(); | 49 void taskCompleted(); |
50 | 50 |
51 #if ENABLE(ASSERT) | 51 #if ENABLE(ASSERT) |
52 bool hasCheckedForTermination() const { return m_hasCheckedForTermination; } | 52 bool hasCheckedForTermination() const { return m_hasCheckedForTermination; } |
53 void setHasCheckedForTermination() { m_hasCheckedForTermination = true; } | 53 void setHasCheckedForTermination() { m_hasCheckedForTermination = true; } |
54 #endif | 54 #endif |
55 | 55 |
56 private: | 56 private: |
57 void waitForTaskCompletionInternal(); | 57 void waitForTaskCompletionInternal(); |
58 | 58 |
59 bool m_taskCompleted; | 59 bool m_taskCompleted; |
60 Mutex m_synchronousMutex; | 60 Mutex m_synchronousMutex; |
61 ThreadCondition m_synchronousCondition; | 61 ThreadCondition m_synchronousCondition; |
62 #if ENABLE(ASSERT) | 62 #if ENABLE(ASSERT) |
63 bool m_hasCheckedForTermination; | 63 bool m_hasCheckedForTermination; |
64 #endif | 64 #endif |
65 }; | 65 }; |
66 | 66 |
67 } // namespace WebCore | 67 } // namespace blink |
68 | 68 |
69 #endif // TaskSynchronizer_h | 69 #endif // TaskSynchronizer_h |
OLD | NEW |