xref: /aosp_15_r20/external/libchrome/base/task_scheduler/task_tracker_posix.cc (revision 635a864187cb8b6c713ff48b7e790a6b21769273)
1 // Copyright 2016 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/task_scheduler/task_tracker_posix.h"
6 
7 #include <utility>
8 
9 #include "base/files/file_descriptor_watcher_posix.h"
10 
11 namespace base {
12 namespace internal {
13 
TaskTrackerPosix(StringPiece name)14 TaskTrackerPosix::TaskTrackerPosix(StringPiece name) : TaskTracker(name) {}
15 TaskTrackerPosix::~TaskTrackerPosix() = default;
16 
RunOrSkipTask(Task task,Sequence * sequence,bool can_run_task)17 void TaskTrackerPosix::RunOrSkipTask(Task task,
18                                      Sequence* sequence,
19                                      bool can_run_task) {
20   DCHECK(watch_file_descriptor_message_loop_);
21   FileDescriptorWatcher file_descriptor_watcher(
22       watch_file_descriptor_message_loop_);
23   TaskTracker::RunOrSkipTask(std::move(task), sequence, can_run_task);
24 }
25 
26 #if DCHECK_IS_ON()
IsPostingBlockShutdownTaskAfterShutdownAllowed()27 bool TaskTrackerPosix::IsPostingBlockShutdownTaskAfterShutdownAllowed() {
28   return service_thread_handle_.is_equal(PlatformThread::CurrentHandle());
29 }
30 #endif
31 
32 }  // namespace internal
33 }  // namespace base
34