Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6347)

Unified Diff: base/mac/libdispatch_task_runner.h

Issue 2123333003: Remove base::mac::LibDispatchTaskRunner and migrate its sole client to plain libdispatch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/mac/libdispatch_task_runner.h
diff --git a/base/mac/libdispatch_task_runner.h b/base/mac/libdispatch_task_runner.h
deleted file mode 100644
index b479bc7aa2bd58481beee854fa6453ccfc18085e..0000000000000000000000000000000000000000
--- a/base/mac/libdispatch_task_runner.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BASE_MAC_LIBDISPATCH_TASK_RUNNER_H_
-#define BASE_MAC_LIBDISPATCH_TASK_RUNNER_H_
-
-#include <dispatch/dispatch.h>
-
-#include "base/single_thread_task_runner.h"
-#include "base/synchronization/waitable_event.h"
-
-namespace base {
-namespace mac {
-
-// This is an implementation of the TaskRunner interface that runs closures on
-// a thread managed by Apple's libdispatch. This has the benefit of being able
-// to PostTask() and friends to a dispatch queue, while being reusable as a
-// dispatch_queue_t.
-//
-// One would use this class if an object lives exclusively on one thread but
-// needs a dispatch_queue_t for use in a system API. This ensures all dispatch
-// callbacks happen on the same thread as Closure tasks.
-//
-// A LibDispatchTaskRunner will continue to run until all references to the
-// underlying dispatch queue are released.
-//
-// Important Notes:
-// - There is no MessageLoop running on this thread, and ::current() returns
-// NULL.
-// - No nested loops can be run, and all tasks are run non-nested.
-// - Work scheduled via libdispatch runs at the same priority as and is
-// interleaved with posted tasks, though FIFO order is guaranteed.
-//
-class BASE_EXPORT LibDispatchTaskRunner : public base::SingleThreadTaskRunner {
- public:
- // Starts a new serial dispatch queue with a given name.
- explicit LibDispatchTaskRunner(const char* name);
-
- // base::TaskRunner:
- bool PostDelayedTask(const tracked_objects::Location& from_here,
- const Closure& task,
- base::TimeDelta delay) override;
- bool RunsTasksOnCurrentThread() const override;
-
- // base::SequencedTaskRunner:
- bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const Closure& task,
- base::TimeDelta delay) override;
-
- // This blocks the calling thread until all work on the dispatch queue has
- // been run and the queue has been destroyed. Destroying a queue requires
- // ALL retained references to it to be released. Any new tasks posted to
- // this thread after shutdown are dropped.
- void Shutdown();
-
- // Returns the dispatch queue associated with this task runner, for use with
- // system APIs that take dispatch queues. The caller is responsible for
- // retaining the result.
- //
- // All properties (context, finalizer, etc.) are managed by this class, and
- // clients should only use the result of this for dispatch_async().
- dispatch_queue_t GetDispatchQueue() const;
-
- protected:
- ~LibDispatchTaskRunner() override;
-
- private:
- static void Finalizer(void* context);
-
- dispatch_queue_t queue_;
-
- // The event on which Shutdown waits until Finalizer runs.
- base::WaitableEvent queue_finalized_;
-};
-
-} // namespace mac
-} // namespace base
-
-#endif // BASE_MAC_LIBDISPATCH_TASK_RUNNER_H_

Powered by Google App Engine
This is Rietveld 408576698