Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scheduler_based_abstract_lock.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef PAGESPEED_KERNEL_THREAD_SCHEDULER_BASED_ABSTRACT_LOCK_H_
20 #define PAGESPEED_KERNEL_THREAD_SCHEDULER_BASED_ABSTRACT_LOCK_H_
21 
24 
25 namespace net_instaweb {
26 
27 class Function;
28 class Scheduler;
29 
41  public:
42  virtual ~SchedulerBasedAbstractLock();
43 
44  virtual bool LockTimedWait(int64 wait_ms);
45  virtual void LockTimedWait(int64 wait_ms, Function* callback);
46 
47  virtual bool LockTimedWaitStealOld(int64 wait_ms, int64 steal_ms);
48  virtual void LockTimedWaitStealOld(
49  int64 wait_ms, int64 steal_ms, Function* callback);
50 
51  protected:
52  friend class SharedMemLockManagerTestBase;
53  friend class FileSystemLockManagerTest;
54 
59  virtual bool TryLock() = 0;
60 
65  virtual bool TryLockStealOld(int64 steal_ms) = 0;
66 
67  virtual Scheduler* scheduler() const = 0;
68 
69  private:
70  typedef bool (SchedulerBasedAbstractLock::*TryLockMethod)(int64 steal_ms);
71  bool TryLockIgnoreSteal(int64 steal_ignored);
72  bool BusySpin(TryLockMethod try_lock, int64 steal_ms);
73  void PollAndCallback(TryLockMethod try_lock, int64 steal_ms,
74  int64 wait_ms, Function* callback);
75 };
76 
77 }
78 
79 #endif
Non-blocking locking class.
Definition: named_lock_manager.h:31
Definition: function.h:47
virtual bool TryLockStealOld(int64 steal_ms)=0
Definition: scheduler.h:47
Definition: scheduler_based_abstract_lock.h:40
Definition: shared_mem_lock_manager_test_base.h:34