distortos  v0.6.0
object-oriented C++ RTOS for microcontrollers
DeferredThreadDeleter.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_INTERNAL_MEMORY_DEFERREDTHREADDELETER_HPP_
13 #define INCLUDE_DISTORTOS_INTERNAL_MEMORY_DEFERREDTHREADDELETER_HPP_
14 
16 
17 #ifdef CONFIG_THREAD_DETACH_ENABLE
18 
19 #include "distortos/Mutex.hpp"
20 
21 namespace distortos
22 {
23 
24 namespace internal
25 {
26 
29 {
30 public:
31 
36  constexpr DeferredThreadDeleter() :
37  list_{},
38  mutex_{Mutex::Protocol::priorityInheritance},
39  notEmpty_{}
40  {
41 
42  }
43 
59  int operator()(ThreadControlBlock& threadControlBlock);
60 
74  int lock();
75 
91  int tryCleanup();
92 
93 private:
94 
103  int tryCleanupInternal();
104 
107 
110 
112  volatile bool notEmpty_;
113 };
114 
115 } // namespace internal
116 
117 } // namespace distortos
118 
119 #endif // def CONFIG_THREAD_DETACH_ENABLE
120 
121 #endif // INCLUDE_DISTORTOS_INTERNAL_MEMORY_DEFERREDTHREADDELETER_HPP_
IntrusiveList class is an intrusive circular doubly linked list.
Definition: IntrusiveList.hpp:927
int tryCleanupInternal()
Internals of tryCleanup().
Definition: DeferredThreadDeleter.cpp:72
constexpr DeferredThreadDeleter()
DeferredThreadDeleter's constructor.
Definition: DeferredThreadDeleter.hpp:36
ThreadList::UnsortedIntrusiveList list_
list of threads scheduled for deferred deletion
Definition: DeferredThreadDeleter.hpp:106
int lock()
Locks the object, preparing it for adding thread to internal list.
Definition: DeferredThreadDeleter.cpp:39
Mutex class header.
int operator()(ThreadControlBlock &threadControlBlock)
DeferredThreadDeleter's function call operator.
Definition: DeferredThreadDeleter.cpp:31
DeferredThreadDeleter class can be used to defer deletion of dynamic detached threads.
Definition: DeferredThreadDeleter.hpp:28
distortos configuration
Top-level namespace of distortos project.
Mutex is the basic synchronization primitive.
Definition: Mutex.hpp:30
volatile bool notEmpty_
true if list_ is not empty, false otherwise
Definition: DeferredThreadDeleter.hpp:112
int tryCleanup()
Tries to perform deferred deletion of threads.
Definition: DeferredThreadDeleter.cpp:44
Mutex mutex_
mutex that synchronizes access to the list_
Definition: DeferredThreadDeleter.hpp:109