embkernel
 All Classes Functions Variables Typedefs Groups Pages
RtosSyncObject.hpp
1 //------------------------------------------------------------------------------
2 //This file is part of embKernel.
3 //See license.txt for the full license governing this code.
4 //------------------------------------------------------------------------------
8 #ifndef RTOS_SYNC_OBJ_HPP_
9 #define RTOS_SYNC_OBJ_HPP_
10 
11 #include "Rtos.hpp"
12 #include "RtosList.hpp"
13 #include "RtosPortable.hpp"
14 
21 protected:
22  RtosSyncObject(int maxCount, int initialCount);
23  ~RtosSyncObject();
24 
25  int mCurrentCount;
26  int mMaxCount;
27 
28  int internalTake(Rtos::TICK tick, int value);
29  void internalWakeUpWaitingToTake();
30  int internalGive(Rtos::TICK tick, int value);
31  void internalWakeUpWaitingToGive();
32 
33  inline void exitCritical() {
34  RtosPortable::exitCriticalSection();
35  }
36 
37 private:
38  RtosList mWaitingToTake;
39  RtosList mWaitingToGive;
40  bool putOnWaitList(RtosTask* task, Rtos::TICK tick, RtosList* list);
41 
42 public:
43  inline int getCount() {
44  return mCurrentCount;
45  }
46  inline int getMaxCount() {
47  return mMaxCount;
48  }
49 };
50 
51 #endif /* RTOS_SYNC_OBJ_HPP_ */
52