OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/executor.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" |
| 9 #include "base/threading/post_task_and_reply_impl.h" |
| 10 |
| 11 namespace base { |
| 12 |
| 13 namespace { |
| 14 |
| 15 class PostTaskAndReplyExecutor : public internal::PostTaskAndReplyImpl { |
| 16 public: |
| 17 PostTaskAndReplyExecutor(Executor* destination); |
| 18 |
| 19 private: |
| 20 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 21 const Closure& task) OVERRIDE; |
| 22 |
| 23 // Non-owning. |
| 24 Executor* destination_; |
| 25 }; |
| 26 |
| 27 PostTaskAndReplyExecutor::PostTaskAndReplyExecutor( |
| 28 Executor* destination) : destination_(destination) {} |
| 29 |
| 30 bool PostTaskAndReplyExecutor::PostTask( |
| 31 const tracked_objects::Location& from_here, |
| 32 const Closure& task) { |
| 33 return destination_->PostTask(from_here, task); |
| 34 } |
| 35 |
| 36 } // namespace |
| 37 |
| 38 bool Executor::PostTaskAndReply( |
| 39 const tracked_objects::Location& from_here, |
| 40 const Closure& task, |
| 41 const Closure& reply) { |
| 42 return PostTaskAndReplyExecutor(this).PostTaskAndReply( |
| 43 from_here, task, reply); |
| 44 } |
| 45 |
| 46 Executor::Executor() {} |
| 47 |
| 48 Executor::~Executor() {} |
| 49 |
| 50 void Executor::OnDestruct() const { |
| 51 delete this; |
| 52 } |
| 53 |
| 54 void ExecutorTraits::Destruct(const Executor* executor) { |
| 55 executor->OnDestruct(); |
| 56 } |
| 57 |
| 58 bool Executor::DeleteSoonInternal( |
| 59 const tracked_objects::Location& from_here, |
| 60 void(*deleter)(const void*), |
| 61 const void* object) { |
| 62 return PostNonNestableTask(from_here, Bind(deleter, object)); |
| 63 } |
| 64 |
| 65 bool Executor::ReleaseSoonInternal( |
| 66 const tracked_objects::Location& from_here, |
| 67 void(*releaser)(const void*), |
| 68 const void* object) { |
| 69 return PostNonNestableTask(from_here, Bind(releaser, object)); |
| 70 } |
| 71 |
| 72 } // namespace base |
OLD | NEW |