Home | History | Annotate | Download | only in task_scheduler
      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 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_LOCK_IMPL_H
      6 #define BASE_TASK_SCHEDULER_SCHEDULER_LOCK_IMPL_H
      7 
      8 #include <memory>
      9 
     10 #include "base/base_export.h"
     11 #include "base/macros.h"
     12 #include "base/synchronization/lock.h"
     13 
     14 namespace base {
     15 
     16 class ConditionVariable;
     17 
     18 namespace internal {
     19 
     20 // A regular lock with simple deadlock correctness checking.
     21 // This lock tracks all of the available locks to make sure that any locks are
     22 // acquired in an expected order.
     23 // See scheduler_lock.h for details.
     24 class BASE_EXPORT SchedulerLockImpl {
     25  public:
     26   SchedulerLockImpl();
     27   explicit SchedulerLockImpl(const SchedulerLockImpl* predecessor);
     28   ~SchedulerLockImpl();
     29 
     30   void Acquire();
     31   void Release();
     32 
     33   void AssertAcquired() const;
     34 
     35   std::unique_ptr<ConditionVariable> CreateConditionVariable();
     36 
     37  private:
     38   Lock lock_;
     39 
     40   DISALLOW_COPY_AND_ASSIGN(SchedulerLockImpl);
     41 };
     42 
     43 }  // namespace internal
     44 }  // namespace base
     45 
     46 #endif  // BASE_TASK_SCHEDULER_SCHEDULER_LOCK_IMPL_H
     47