| OLD | NEW |
| 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 #include "base/mac/libdispatch_task_runner.h" | 5 #include "base/mac/libdispatch_task_runner.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 namespace mac { | 12 namespace mac { |
| 13 | 13 |
| 14 LibDispatchTaskRunner::LibDispatchTaskRunner(const char* name) | 14 LibDispatchTaskRunner::LibDispatchTaskRunner(const char* name) |
| 15 : queue_(dispatch_queue_create(name, NULL)), | 15 : queue_(dispatch_queue_create(name, NULL)), |
| 16 queue_finalized_(false, false) { | 16 queue_finalized_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 17 base::WaitableEvent::InitialState::NOT_SIGNALED) { |
| 17 dispatch_set_context(queue_, this); | 18 dispatch_set_context(queue_, this); |
| 18 dispatch_set_finalizer_f(queue_, &LibDispatchTaskRunner::Finalizer); | 19 dispatch_set_finalizer_f(queue_, &LibDispatchTaskRunner::Finalizer); |
| 19 } | 20 } |
| 20 | 21 |
| 21 bool LibDispatchTaskRunner::PostDelayedTask( | 22 bool LibDispatchTaskRunner::PostDelayedTask( |
| 22 const tracked_objects::Location& from_here, | 23 const tracked_objects::Location& from_here, |
| 23 const Closure& task, | 24 const Closure& task, |
| 24 base::TimeDelta delay) { | 25 base::TimeDelta delay) { |
| 25 if (!queue_) | 26 if (!queue_) |
| 26 return false; | 27 return false; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 74 } |
| 74 } | 75 } |
| 75 | 76 |
| 76 void LibDispatchTaskRunner::Finalizer(void* context) { | 77 void LibDispatchTaskRunner::Finalizer(void* context) { |
| 77 LibDispatchTaskRunner* self = static_cast<LibDispatchTaskRunner*>(context); | 78 LibDispatchTaskRunner* self = static_cast<LibDispatchTaskRunner*>(context); |
| 78 self->queue_finalized_.Signal(); | 79 self->queue_finalized_.Signal(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 } // namespace mac | 82 } // namespace mac |
| 82 } // namespace base | 83 } // namespace base |
| OLD | NEW |