| 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 26 matching lines...) Expand all Loading... |
| 37 TaskSynchronizer::TaskSynchronizer() | 37 TaskSynchronizer::TaskSynchronizer() |
| 38 : m_taskCompleted(false) | 38 : m_taskCompleted(false) |
| 39 { | 39 { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void TaskSynchronizer::waitForTaskCompletion() | 42 void TaskSynchronizer::waitForTaskCompletion() |
| 43 { | 43 { |
| 44 if (ThreadState::current()) { | 44 if (ThreadState::current()) { |
| 45 // Prevent the deadlock between park request by other threads and blocki
ng | 45 // Prevent the deadlock between park request by other threads and blocki
ng |
| 46 // by m_synchronousCondition. | 46 // by m_synchronousCondition. |
| 47 SafePointScope scope(ThreadState::HeapPointersOnStack); | 47 SafePointScope scope(BlinkGC::HeapPointersOnStack); |
| 48 waitForTaskCompletionInternal(); | 48 waitForTaskCompletionInternal(); |
| 49 } else { | 49 } else { |
| 50 // If this thread is already detached, we no longer need to enter a safe
point scope. | 50 // If this thread is already detached, we no longer need to enter a safe
point scope. |
| 51 waitForTaskCompletionInternal(); | 51 waitForTaskCompletionInternal(); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 void TaskSynchronizer::waitForTaskCompletionInternal() | 55 void TaskSynchronizer::waitForTaskCompletionInternal() |
| 56 { | 56 { |
| 57 m_synchronousMutex.lock(); | 57 m_synchronousMutex.lock(); |
| 58 while (!m_taskCompleted) | 58 while (!m_taskCompleted) |
| 59 m_synchronousCondition.wait(m_synchronousMutex); | 59 m_synchronousCondition.wait(m_synchronousMutex); |
| 60 m_synchronousMutex.unlock(); | 60 m_synchronousMutex.unlock(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void TaskSynchronizer::taskCompleted() | 63 void TaskSynchronizer::taskCompleted() |
| 64 { | 64 { |
| 65 m_synchronousMutex.lock(); | 65 m_synchronousMutex.lock(); |
| 66 m_taskCompleted = true; | 66 m_taskCompleted = true; |
| 67 m_synchronousCondition.signal(); | 67 m_synchronousCondition.signal(); |
| 68 m_synchronousMutex.unlock(); | 68 m_synchronousMutex.unlock(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace blink | 71 } // namespace blink |
| OLD | NEW |