[utils] Remove deprecated_loop.

This is a reland of 25be26370eeb1f613bdb139ab6c91750b19cc722

Original change's description:
> [utils] Remove deprecated_loop.
>
> All clients have been converted to libasync*.
>
> Change-Id: I7df2f9265b31e8b2489a78e8ef71090aea2e86c1

Change-Id: I09ca54702385995914bc34f44c1b81cb0811738a
diff --git a/lib/deprecated_loop/BUILD.gn b/lib/deprecated_loop/BUILD.gn
deleted file mode 100644
index 3889254..0000000
--- a/lib/deprecated_loop/BUILD.gn
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright 2018 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/package.gni")
-import("//build/testing/environments.gni")
-
-source_set("deprecated_loop") {
-  sources = [
-    "incoming_task_queue.cc",
-    "incoming_task_queue.h",
-    "message_loop.cc",
-    "message_loop.h",
-    "thread.cc",
-    "thread.h",
-  ]
-  public_deps = [
-    "//garnet/public/lib/fxl",
-    "//zircon/public/lib/async-default",
-    "//zircon/public/lib/async-loop-cpp",
-    "//zircon/public/lib/async-testutils",
-    "//zircon/public/lib/fdio",
-    "//zircon/public/lib/zx",
-  ]
-}
-
-executable("deprecated_loop_unittests") {
-  testonly = true
-  sources = [
-    "message_loop_unittest.cc",
-    "thread_unittest.cc",
-  ]
-
-  deps = [
-    ":deprecated_loop",
-    "//garnet/public/lib/fsl",
-    "//garnet/public/lib/fxl/test:gtest_main",
-    "//third_party/googletest:gtest",
-  ]
-}
-
-package("deprecated_loop_tests") {
-  testonly = true
-  deps = [
-    ":deprecated_loop_unittests",
-  ]
-
-  tests = [
-    {
-      name = "deprecated_loop_unittests"
-      environments = basic_envs
-    },
-  ]
-}
diff --git a/lib/deprecated_loop/incoming_task_queue.cc b/lib/deprecated_loop/incoming_task_queue.cc
deleted file mode 100644
index 20a5910..0000000
--- a/lib/deprecated_loop/incoming_task_queue.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/lib/deprecated_loop/incoming_task_queue.h"
-
-namespace deprecated_loop {
-namespace internal {
-
-TaskQueueDelegate::~TaskQueueDelegate() {}
-
-IncomingTaskQueue::IncomingTaskQueue() {}
-
-IncomingTaskQueue::~IncomingTaskQueue() {}
-
-void IncomingTaskQueue::PostTask(fxl::Closure task) {
-  AddTask(std::move(task), fxl::TimePoint());
-}
-
-void IncomingTaskQueue::PostTaskForTime(fxl::Closure task,
-                                        fxl::TimePoint target_time) {
-  AddTask(std::move(task), target_time);
-}
-
-void IncomingTaskQueue::PostDelayedTask(fxl::Closure task,
-                                        fxl::TimeDelta delay) {
-  AddTask(std::move(task), delay > fxl::TimeDelta::Zero()
-                               ? fxl::TimePoint::Now() + delay
-                               : fxl::TimePoint());
-}
-
-void IncomingTaskQueue::AddTask(fxl::Closure task, fxl::TimePoint target_time) {
-  std::lock_guard<std::mutex> locker(mutex_);
-
-  if (drop_incoming_tasks_)
-    return;
-  if (delegate_) {
-    delegate_->PostTask(std::move(task), target_time);
-  } else {
-    incoming_queue_.emplace_back(std::move(task), target_time);
-  }
-}
-
-bool IncomingTaskQueue::RunsTasksOnCurrentThread() {
-  std::lock_guard<std::mutex> locker(mutex_);
-  return delegate_ && delegate_->RunsTasksOnCurrentThread();
-}
-
-void IncomingTaskQueue::InitDelegate(TaskQueueDelegate* delegate) {
-  FXL_DCHECK(delegate);
-
-  std::lock_guard<std::mutex> locker(mutex_);
-  FXL_DCHECK(!drop_incoming_tasks_);
-
-  delegate_ = delegate;
-  for (auto& task : incoming_queue_)
-    delegate_->PostTask(std::move(task.first), task.second);
-  incoming_queue_.clear();
-}
-
-void IncomingTaskQueue::ClearDelegate() {
-  std::lock_guard<std::mutex> locker(mutex_);
-
-  FXL_DCHECK(!drop_incoming_tasks_);
-  drop_incoming_tasks_ = true;
-  delegate_ = nullptr;
-}
-
-}  // namespace internal
-}  // namespace deprecated_loop
diff --git a/lib/deprecated_loop/incoming_task_queue.h b/lib/deprecated_loop/incoming_task_queue.h
deleted file mode 100644
index 0264a5d..0000000
--- a/lib/deprecated_loop/incoming_task_queue.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2018 The Fuchsia 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 LIB_DEPRECATED_LOOP_INCOMING_TASK_QUEUE_H_
-#define LIB_DEPRECATED_LOOP_INCOMING_TASK_QUEUE_H_
-
-#include <mutex>
-#include <utility>
-#include <vector>
-
-#include "lib/fxl/functional/closure.h"
-#include "lib/fxl/fxl_export.h"
-#include "lib/fxl/macros.h"
-#include "lib/fxl/memory/ref_counted.h"
-#include "lib/fxl/synchronization/thread_annotations.h"
-#include "lib/fxl/tasks/task_runner.h"
-#include "lib/fxl/time/time_point.h"
-
-namespace deprecated_loop {
-namespace internal {
-
-class FXL_EXPORT TaskQueueDelegate {
- public:
-  virtual void PostTask(fxl::Closure task, fxl::TimePoint target_time) = 0;
-  virtual bool RunsTasksOnCurrentThread() = 0;
-
- protected:
-  virtual ~TaskQueueDelegate();
-};
-
-// Receives tasks from multiple threads and buffers them until a delegate
-// is ready to receive them.
-//
-// This object is threadsafe.
-class FXL_EXPORT IncomingTaskQueue : public fxl::TaskRunner {
- public:
-  IncomingTaskQueue();
-  ~IncomingTaskQueue() override;
-
-  // |TaskRunner| implementation:
-  void PostTask(fxl::Closure task) override;
-  void PostTaskForTime(fxl::Closure task, fxl::TimePoint target_time) override;
-  void PostDelayedTask(fxl::Closure task, fxl::TimeDelta delay) override;
-  bool RunsTasksOnCurrentThread() override;
-
-  // Sets the delegate and schedules all pending tasks with it.
-  void InitDelegate(TaskQueueDelegate* delegate);
-
-  // Clears the delegate and drops all later incoming tasks.
-  void ClearDelegate();
-
- private:
-  void AddTask(fxl::Closure task, fxl::TimePoint target_time);
-
-  using Task = std::pair<fxl::Closure, fxl::TimePoint>;
-
-  std::mutex mutex_;
-  std::vector<Task> incoming_queue_ FXL_GUARDED_BY(mutex_);
-  TaskQueueDelegate* delegate_ FXL_GUARDED_BY(mutex_) = nullptr;
-  bool drop_incoming_tasks_ FXL_GUARDED_BY(mutex_) = false;
-
-  FXL_DISALLOW_COPY_AND_ASSIGN(IncomingTaskQueue);
-};
-
-}  // namespace internal
-}  // namespace deprecated_loop
-
-#endif  // LIB_DEPRECATED_LOOP_INCOMING_TASK_QUEUE_H_
diff --git a/lib/deprecated_loop/message_loop.cc b/lib/deprecated_loop/message_loop.cc
deleted file mode 100644
index 633987f..0000000
--- a/lib/deprecated_loop/message_loop.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/lib/deprecated_loop/message_loop.h"
-
-#include <utility>
-
-#include <lib/async/cpp/task.h>
-#include <zircon/syscalls.h>
-
-#include "lib/fxl/logging.h"
-
-namespace deprecated_loop {
-namespace {
-
-thread_local MessageLoop* g_current;
-
-}  // namespace
-
-MessageLoop::MessageLoop()
-    : MessageLoop(fxl::MakeRefCounted<internal::IncomingTaskQueue>()) {}
-
-MessageLoop::MessageLoop(
-    fxl::RefPtr<internal::IncomingTaskQueue> incoming_tasks)
-    : loop_config_{.make_default_for_current_thread = true,
-                   .epilogue = &MessageLoop::Epilogue,
-                   .data = this},
-      loop_(&loop_config_),
-      task_runner_(std::move(incoming_tasks)) {
-  FXL_DCHECK(!g_current) << "At most one message loop per thread.";
-  g_current = this;
-
-  MessageLoop::incoming_tasks()->InitDelegate(this);
-}
-
-MessageLoop::~MessageLoop() {
-  FXL_DCHECK(g_current == this)
-      << "Message loops must be destroyed on their own threads.";
-
-  loop_.Shutdown();
-
-  incoming_tasks()->ClearDelegate();
-
-  g_current = nullptr;
-}
-
-MessageLoop* MessageLoop::GetCurrent() { return g_current; }
-
-void MessageLoop::PostTask(fxl::Closure task, fxl::TimePoint target_time) {
-  zx_status_t status = async::PostTaskForTime(
-      loop_.dispatcher(), [task = std::move(task)] { task(); },
-      zx::time(target_time.ToEpochDelta().ToNanoseconds()));
-  FXL_CHECK(status == ZX_OK || status == ZX_ERR_BAD_STATE)
-      << "Failed to post task: status=" << status;
-}
-
-void MessageLoop::Run(bool until_idle) {
-  FXL_DCHECK(g_current == this);
-
-  FXL_CHECK(!is_running_) << "Cannot run a nested message loop.";
-  is_running_ = true;
-
-  zx_status_t status = until_idle ? loop_.RunUntilIdle() : loop_.Run();
-  FXL_CHECK(status == ZX_OK || status == ZX_ERR_CANCELED)
-      << "Loop stopped abnormally: status=" << status;
-
-  status = loop_.ResetQuit();
-  FXL_DCHECK(status == ZX_OK)
-      << "Failed to reset quit state: status=" << status;
-
-  FXL_DCHECK(is_running_);
-  is_running_ = false;
-}
-
-void MessageLoop::Run() { Run(false); }
-
-void MessageLoop::RunUntilIdle() { Run(true); }
-
-void MessageLoop::QuitNow() {
-  FXL_DCHECK(g_current == this);
-
-  if (is_running_)
-    loop_.Quit();
-}
-
-void MessageLoop::PostQuitTask() {
-  task_runner()->PostTask([this]() { QuitNow(); });
-}
-
-bool MessageLoop::RunsTasksOnCurrentThread() { return g_current == this; }
-
-void MessageLoop::SetAfterTaskCallback(fxl::Closure callback) {
-  FXL_DCHECK(g_current == this);
-
-  after_task_callback_ = std::move(callback);
-}
-
-void MessageLoop::ClearAfterTaskCallback() {
-  FXL_DCHECK(g_current == this);
-
-  after_task_callback_ = fxl::Closure();
-}
-
-void MessageLoop::Epilogue(async_loop_t*, void* data) {
-  auto loop = static_cast<MessageLoop*>(data);
-  if (loop->after_task_callback_)
-    loop->after_task_callback_();
-}
-
-}  // namespace deprecated_loop
diff --git a/lib/deprecated_loop/message_loop.h b/lib/deprecated_loop/message_loop.h
deleted file mode 100644
index 697410d..0000000
--- a/lib/deprecated_loop/message_loop.h
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2016 The Fuchsia 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 LIB_DEPRECATED_LOOP_MESSAGE_LOOP_H_
-#define LIB_DEPRECATED_LOOP_MESSAGE_LOOP_H_
-
-#include <map>
-
-#include <lib/async-loop/cpp/loop.h>
-
-#include "lib/fxl/fxl_export.h"
-#include "lib/fxl/macros.h"
-#include "lib/fxl/memory/ref_ptr.h"
-#include "lib/fxl/tasks/task_runner.h"
-#include "topaz/lib/deprecated_loop/incoming_task_queue.h"
-
-namespace deprecated_loop {
-
-// DEPRECATED: please use async::Loop instead.
-class FXL_EXPORT MessageLoop : private internal::TaskQueueDelegate {
- public:
-  using HandlerKey = uint64_t;
-
-  // Constructs a message loop with an empty task queue. The message loop is
-  // bound to the current thread.
-  MessageLoop();
-
-  // Constructs a message loop that will begin by draining the tasks already
-  // present in the |incoming_tasks| queue. The message loop is bound to the
-  // current thread.
-  explicit MessageLoop(fxl::RefPtr<internal::IncomingTaskQueue> incoming_tasks);
-
-  ~MessageLoop() override;
-
-  // Returns the message loop associated with the current thread, if any.
-  static MessageLoop* GetCurrent();
-
-  // Gets the underlying libasync dispatcher.
-  // See <async/dispatcher.h> for details on how to use this.
-  async_dispatcher_t* dispatcher() const { return loop_.dispatcher(); }
-
-  // Return an interface for posting tasks to this message loop.
-  const fxl::RefPtr<fxl::TaskRunner>& task_runner() const {
-    return task_runner_;
-  }
-
-  // The message loop will call |callback| after each task that execute and
-  // after each time it signals a handler. If the message loop already has an
-  // after task callback set, this function will replace it with this one.
-  void SetAfterTaskCallback(fxl::Closure callback);
-
-  // The message loop will no longer call the registered after task callback, if
-  // any.
-  void ClearAfterTaskCallback();
-
-  // Causes the message loop to run tasks until |QuitNow| is called. If no tasks
-  // are available, the message loop with block and wait for tasks to be posted
-  // via the |task_runner|.
-  void Run();
-
-  // Runs until there are no tasks to run and no runnable handlers. This is
-  // useful for unit testing, because the behavior doesn't depend on time.
-  void RunUntilIdle();
-
-  // Prevents further tasks from running and returns from |Run|. Must be called
-  // while |Run| is on the stack.
-  void QuitNow();
-
-  // Posts a task to the queue that calls |QuitNow|. Useful for gracefully
-  // ending the message loop. Can be called whether or not |Run| is on the
-  // stack.
-  void PostQuitTask();
-
- private:
-  // |internal::TaskQueueDelegate| implementation:
-  void PostTask(fxl::Closure task, fxl::TimePoint target_time) override;
-  bool RunsTasksOnCurrentThread() override;
-
-  void Run(bool until_idle);
-
-  static void Epilogue(async_loop_t* loop, void* data);
-
-  internal::IncomingTaskQueue* incoming_tasks() {
-    return static_cast<internal::IncomingTaskQueue*>(task_runner_.get());
-  }
-
-  async_loop_config_t loop_config_;
-  async::Loop loop_;
-
-  fxl::RefPtr<fxl::TaskRunner> task_runner_;
-  fxl::Closure after_task_callback_;
-  bool is_running_ = false;
-
-  FXL_DISALLOW_COPY_AND_ASSIGN(MessageLoop);
-};
-
-}  // namespace deprecated_loop
-
-#endif  // LIB_DEPRECATED_LOOP_MESSAGE_LOOP_H_
diff --git a/lib/deprecated_loop/message_loop_unittest.cc b/lib/deprecated_loop/message_loop_unittest.cc
deleted file mode 100644
index f58dfb1..0000000
--- a/lib/deprecated_loop/message_loop_unittest.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/lib/deprecated_loop/message_loop.h"
-
-#include <lib/fdio/io.h>
-#include <lib/zx/channel.h>
-#include <lib/zx/event.h>
-
-#include <poll.h>
-
-#include <functional>
-#include <memory>
-#include <string>
-#include <thread>
-#include <vector>
-
-#include "gtest/gtest.h"
-#include "lib/fsl/tasks/fd_waiter.h"
-#include "src/lib/files/unique_fd.h"
-#include "lib/fxl/functional/closure.h"
-#include "lib/fxl/macros.h"
-
-namespace deprecated_loop {
-namespace {
-
-TEST(MessageLoop, Current) {
-  EXPECT_TRUE(MessageLoop::GetCurrent() == nullptr);
-  {
-    MessageLoop message_loop;
-    EXPECT_EQ(&message_loop, MessageLoop::GetCurrent());
-  }
-  EXPECT_TRUE(MessageLoop::GetCurrent() == nullptr);
-}
-
-TEST(MessageLoop, RunsTasksOnCurrentThread) {
-  fxl::RefPtr<fxl::TaskRunner> task_runner;
-
-  {
-    MessageLoop loop;
-    task_runner = loop.task_runner();
-    EXPECT_TRUE(task_runner->RunsTasksOnCurrentThread());
-    bool run_on_other_thread;
-    std::thread t([task_runner, &run_on_other_thread]() {
-      run_on_other_thread = task_runner->RunsTasksOnCurrentThread();
-    });
-    t.join();
-    EXPECT_FALSE(run_on_other_thread);
-  }
-
-  EXPECT_FALSE(task_runner->RunsTasksOnCurrentThread());
-}
-
-TEST(MessageLoop, CanRunTasks) {
-  bool did_run = false;
-  MessageLoop loop;
-  loop.task_runner()->PostTask([&did_run, &loop]() {
-    EXPECT_FALSE(did_run);
-    did_run = true;
-  });
-  loop.RunUntilIdle();
-  EXPECT_TRUE(did_run);
-}
-
-TEST(MessageLoop, CanPostTasksFromTasks) {
-  bool did_run = false;
-  MessageLoop loop;
-  fxl::Closure nested_task = [&did_run, &loop]() {
-    EXPECT_FALSE(did_run);
-    did_run = true;
-  };
-  loop.task_runner()->PostTask([&nested_task, &loop]() {
-    loop.task_runner()->PostTask(std::move(nested_task));
-  });
-  loop.RunUntilIdle();
-  EXPECT_TRUE(did_run);
-}
-
-TEST(MessageLoop, TriplyNestedTasks) {
-  std::vector<std::string> tasks;
-  MessageLoop loop;
-  loop.task_runner()->PostTask([&tasks, &loop]() {
-    tasks.push_back("one");
-    loop.task_runner()->PostTask([&tasks, &loop]() {
-      tasks.push_back("two");
-      loop.task_runner()->PostTask(
-          [&tasks, &loop]() { tasks.push_back("three"); });
-    });
-  });
-  loop.RunUntilIdle();
-  EXPECT_EQ(3u, tasks.size());
-  EXPECT_EQ("one", tasks[0]);
-  EXPECT_EQ("two", tasks[1]);
-  EXPECT_EQ("three", tasks[2]);
-}
-
-TEST(MessageLoop, CanRunTasksInOrder) {
-  std::vector<std::string> tasks;
-  MessageLoop loop;
-  loop.task_runner()->PostTask([&tasks]() { tasks.push_back("0"); });
-  loop.task_runner()->PostTask([&tasks]() { tasks.push_back("1"); });
-  loop.PostQuitTask();
-  loop.task_runner()->PostTask([&tasks]() { tasks.push_back("2"); });
-  loop.RunUntilIdle();
-  EXPECT_EQ(2u, tasks.size());
-  EXPECT_EQ("0", tasks[0]);
-  EXPECT_EQ("1", tasks[1]);
-}
-
-TEST(MessageLoop, CanPreloadTasks) {
-  auto incoming_queue = fxl::MakeRefCounted<internal::IncomingTaskQueue>();
-
-  bool did_run = false;
-  MessageLoop* loop_ptr = nullptr;
-  incoming_queue->PostTask([&did_run, &loop_ptr]() {
-    EXPECT_FALSE(did_run);
-    did_run = true;
-  });
-
-  MessageLoop loop(std::move(incoming_queue));
-  loop_ptr = &loop;
-  loop.RunUntilIdle();
-  EXPECT_TRUE(did_run);
-}
-
-TEST(MessageLoop, AfterTaskCallbacks) {
-  std::vector<std::string> tasks;
-  MessageLoop loop;
-  loop.SetAfterTaskCallback([&tasks] { tasks.push_back("callback"); });
-  loop.task_runner()->PostTask([&tasks] { tasks.push_back("0"); });
-  loop.task_runner()->PostTask([&tasks] { tasks.push_back("1"); });
-  loop.PostQuitTask();
-  loop.task_runner()->PostTask([&tasks] { tasks.push_back("2"); });
-  loop.RunUntilIdle();
-  EXPECT_EQ(5u, tasks.size());
-  EXPECT_EQ("0", tasks[0]);
-  EXPECT_EQ("callback", tasks[1]);
-  EXPECT_EQ("1", tasks[2]);
-  EXPECT_EQ("callback", tasks[3]);
-}
-
-TEST(MessageLoop, RemoveAfterTaskCallbacksDuringCallback) {
-  std::vector<std::string> tasks;
-  MessageLoop loop;
-
-  loop.SetAfterTaskCallback([&tasks, &loop]() {
-    tasks.push_back("callback");
-    loop.ClearAfterTaskCallback();
-  });
-  loop.task_runner()->PostTask([&tasks] { tasks.push_back("0"); });
-  loop.task_runner()->PostTask([&tasks] { tasks.push_back("1"); });
-  loop.RunUntilIdle();
-  EXPECT_EQ(3u, tasks.size());
-  EXPECT_EQ("0", tasks[0]);
-  EXPECT_EQ("callback", tasks[1]);
-  EXPECT_EQ("1", tasks[2]);
-}
-
-class DestructorObserver {
- public:
-  DestructorObserver(fxl::Closure callback) : callback_(std::move(callback)) {}
-  ~DestructorObserver() { callback_(); }
-
- private:
-  fxl::Closure callback_;
-};
-
-TEST(MessageLoop, TaskDestructionTime) {
-  bool destructed = false;
-  fxl::RefPtr<fxl::TaskRunner> task_runner;
-
-  {
-    MessageLoop loop;
-    task_runner = fxl::RefPtr<fxl::TaskRunner>(loop.task_runner());
-    loop.RunUntilIdle();
-    auto observer1 = std::make_unique<DestructorObserver>(
-        [&destructed] { destructed = true; });
-    task_runner->PostTask([p = std::move(observer1)]() {});
-    EXPECT_FALSE(destructed);
-  }
-  EXPECT_TRUE(destructed);
-
-  destructed = false;
-  auto observer2 = std::make_unique<DestructorObserver>(
-      [&destructed] { destructed = true; });
-  task_runner->PostTask([p = std::move(observer2)]() {});
-  EXPECT_TRUE(destructed);
-}
-
-TEST(MessageLoop, CanQuitCurrent) {
-  int count = 0;
-  MessageLoop loop;
-  loop.task_runner()->PostTask([&count]() {
-    count++;
-    MessageLoop::GetCurrent()->QuitNow();
-  });
-  loop.task_runner()->PostTask([&count]() { count++; });
-  loop.RunUntilIdle();
-  EXPECT_EQ(1, count);
-}
-
-TEST(MessageLoop, CanQuitManyTimes) {
-  MessageLoop loop;
-  loop.QuitNow();
-  loop.QuitNow();
-  loop.PostQuitTask();
-  loop.RunUntilIdle();
-  loop.QuitNow();
-  loop.QuitNow();
-}
-
-// Tests that waiting on files in a MessageLoop works.
-TEST(MessageLoop, FDWaiter) {
-  // Create an event and an FD that reflects that event. The fd
-  // shares ownership of the event.
-  zx::event fdevent;
-  EXPECT_EQ(zx::event::create(0u, &fdevent), ZX_OK);
-  fxl::UniqueFD fd(
-      fdio_handle_fd(fdevent.get(), ZX_USER_SIGNAL_0, 0, /*shared=*/true));
-  EXPECT_TRUE(fd.is_valid());
-
-  bool callback_ran = false;
-  {
-    MessageLoop message_loop;
-    fsl::FDWaiter waiter;
-
-    std::thread thread([&fdevent]() {
-      // Poke the fdevent, which pokes the fd.
-      EXPECT_EQ(fdevent.signal(0u, ZX_USER_SIGNAL_0), ZX_OK);
-    });
-    auto callback = [&callback_ran, &message_loop](zx_status_t success,
-                                                   uint32_t events) {
-      EXPECT_EQ(success, ZX_OK);
-      EXPECT_EQ(events, static_cast<uint32_t>(POLLIN));
-      callback_ran = true;
-      message_loop.QuitNow();
-    };
-    EXPECT_TRUE(waiter.Wait(callback, fd.get(), POLLIN));
-    message_loop.Run();
-    thread.join();
-  }
-
-  EXPECT_TRUE(callback_ran);
-}
-
-}  // namespace
-}  // namespace deprecated_loop
diff --git a/lib/deprecated_loop/thread.cc b/lib/deprecated_loop/thread.cc
deleted file mode 100644
index 6696732..0000000
--- a/lib/deprecated_loop/thread.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/lib/deprecated_loop/thread.h"
-
-#include "topaz/lib/deprecated_loop/incoming_task_queue.h"
-#include "topaz/lib/deprecated_loop/message_loop.h"
-
-namespace deprecated_loop {
-
-Thread::Thread()
-    : thread_([this] { Main(); }),
-      task_runner_(fxl::MakeRefCounted<internal::IncomingTaskQueue>()) {}
-
-Thread::~Thread() {}
-
-bool Thread::Run(size_t stack_size) { return thread_.Run(stack_size); }
-
-bool Thread::IsRunning() const { return thread_.IsRunning(); }
-
-fxl::RefPtr<fxl::TaskRunner> Thread::TaskRunner() const { return task_runner_; }
-
-void Thread::Main(void) {
-  MessageLoop message_loop(task_runner_);
-  message_loop.Run();
-}
-
-bool Thread::Join() { return thread_.Join(); }
-
-}  // namespace deprecated_loop
diff --git a/lib/deprecated_loop/thread.h b/lib/deprecated_loop/thread.h
deleted file mode 100644
index f5fd8a0..0000000
--- a/lib/deprecated_loop/thread.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2017 The Fuchsia 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 LIB_DEPRECATED_LOOP_THREAD_H_
-#define LIB_DEPRECATED_LOOP_THREAD_H_
-
-#include "lib/fxl/fxl_export.h"
-#include "lib/fxl/macros.h"
-#include "lib/fxl/memory/ref_ptr.h"
-#include "lib/fxl/tasks/task_runner.h"
-#include "lib/fxl/threading/thread.h"
-#include "topaz/lib/deprecated_loop/incoming_task_queue.h"
-
-namespace deprecated_loop {
-
-namespace internal {
-class IncomingTaskQueue;
-}  // namespace internal
-
-// DEPRECATED
-class FXL_EXPORT Thread {
- public:
-  static constexpr size_t default_stack_size = 1 * 1024 * 1024;
-
-  Thread();
-  ~Thread();
-  bool Run(size_t stack_size = default_stack_size);
-  bool IsRunning() const;
-  bool Join();
-  fxl::RefPtr<fxl::TaskRunner> TaskRunner() const;
-
- private:
-  void Main();
-
-  fxl::Thread thread_;
-  fxl::RefPtr<internal::IncomingTaskQueue> task_runner_;
-
-  FXL_DISALLOW_COPY_AND_ASSIGN(Thread);
-};
-
-}  // namespace deprecated_loop
-
-#endif  // LIB_DEPRECATED_LOOP_THREAD_H_
diff --git a/lib/deprecated_loop/thread_unittest.cc b/lib/deprecated_loop/thread_unittest.cc
deleted file mode 100644
index faac0ee..0000000
--- a/lib/deprecated_loop/thread_unittest.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "topaz/lib/deprecated_loop/thread.h"
-
-#include "gtest/gtest.h"
-#include "topaz/lib/deprecated_loop/message_loop.h"
-
-namespace deprecated_loop {
-namespace {
-
-TEST(Thread, Control) {
-  Thread thread;
-  EXPECT_FALSE(thread.IsRunning());
-  EXPECT_TRUE(thread.Run());
-  EXPECT_TRUE(thread.IsRunning());
-  thread.TaskRunner()->PostTask(
-      [] { MessageLoop::GetCurrent()->QuitNow(); });
-  EXPECT_TRUE(thread.Join());
-}
-
-}  // namespace
-}  // namespace deprecated_loop
diff --git a/packages/tests/all b/packages/tests/all
index 35f3d89..2a3ee09 100644
--- a/packages/tests/all
+++ b/packages/tests/all
@@ -9,7 +9,6 @@
         "topaz/packages/tests/dart_target_unittests",
         "topaz/packages/tests/dart_target_integration_tests",
         "topaz/packages/tests/dart_unittests",
-        "topaz/packages/tests/deprecated_loop",
         "topaz/packages/tests/fidl_changes",
         "topaz/packages/tests/fidl_compatibility_test",
         "topaz/packages/tests/fidl_compatibility_test_server_dart",
diff --git a/packages/tests/deprecated_loop b/packages/tests/deprecated_loop
deleted file mode 100644
index 197acea..0000000
--- a/packages/tests/deprecated_loop
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    "packages": [
-        "//topaz/lib/deprecated_loop:deprecated_loop_tests"
-    ]
-}