Skip to content

Commit 5414cbf

Browse files
fixes #150 @2h
1 parent 9c989ea commit 5414cbf

File tree

6 files changed

+249
-230
lines changed

6 files changed

+249
-230
lines changed

.gitignore

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,49 @@
1-
# Compiled Object files
2-
*.slo
3-
*.lo
4-
*.o
5-
*.obj
6-
core
7-
8-
# Precompiled Headers
9-
*.gch
10-
*.pch
1+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
2+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
113

12-
# Compiled Dynamic libraries
13-
*.so
14-
*.dylib
15-
*.dll
4+
# build directories
5+
target/**
6+
build/**
7+
cmake-build*/
8+
delivery/**
169

17-
# Fortran module files
18-
*.mod
10+
# SONAR Qube related working directories
11+
.scannerwork
1912

20-
# Compiled Static libraries
21-
*.dSYM
22-
*.lai
23-
*.la
13+
# extension
14+
*.swp
15+
*.o
2416
*.a
25-
*.lib
26-
27-
# Executables
28-
*.exe
29-
*.out
30-
*.app
31-
tests/*tests
17+
*.so
18+
*.class
19+
*.dll
3220

33-
# emacs
34-
*~
21+
# IDE related stiff
22+
.idea/**
3523

36-
# Xcode
37-
*.xcodeproj/
38-
DerivedData/
24+
# File-based project format
25+
*.iws
3926

40-
# MAc OS X
41-
.DS_Store
42-
*.icloud
27+
# IntelliJ
28+
out/
4329

44-
# MAc OS X
45-
.DS_Store
46-
._*
30+
# JIRA plugin
31+
atlassian-ide-plugin.xml
4732

48-
# Code check
49-
.sonar
33+
# Crashlytics plugin (for Android Studio and IntelliJ)
34+
com_crashlytics_export_strings.xml
35+
crashlytics.properties
36+
crashlytics-build.properties
37+
fabric.properties
5038

51-
# autoconf
39+
# special files
5240
config.h
53-
autom4te.cache
54-
config.status
55-
config.log
56-
Makefile
5741

58-
# IDEA
59-
.idea
60-
61-
# CMake
62-
*build*
42+
.DS_Store
43+
doc
6344

64-
CMakeCache.txt
65-
CMakeFiles
66-
CMakeScripts
67-
Testing
68-
Makefile
69-
cmake_install.cmake
70-
install_manifest.txt
71-
compile_commands.json
72-
CTestTestfile.cmake
45+
*.xcode*
7346

74-
# layout
75-
.scannerwork
76-
doxyfile
77-
*.tar
78-
sonar-project.properties
79-
distrib/
80-
lib/
81-
doc/
8247
*-tests
48+
*_tests
8349

84-
# Images
85-
*.png

include/pthread/condition_variable.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ namespace pthread {
188188
void notify_all () noexcept ;
189189
#endif
190190

191+
/**
192+
* not copy-assignable
193+
*/
194+
void operator=( const condition_variable &) = delete;
195+
191196
// constructor/destructor ------------------------------------------------
192197

193198
condition_variable ();
@@ -197,7 +202,7 @@ namespace pthread {
197202
void milliseconds( int milliseconds);
198203

199204
timespec timeout;
200-
pthread_cond_t _condition;
205+
pthread_cond_t _condition; //!< NOSONAR this union is declared in the POSIX Threading library. It cannot be changed (ignoring rule MISRA C++:2008, 9-5-1 - Unions shall not be used.)
201206
};
202207

203208
/** @} */

include/pthread/lock_guard.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ namespace pthread {
5353

5454
/** The destructor release the guarded mutex.
5555
*/
56-
~lock_guard() {
56+
~lock_guard() {
5757
_mutex->unlock();
58-
}
58+
}
59+
60+
/**
61+
* Cannot be copied.
62+
*/
63+
lock_guard( const lock_guard &) = delete;
5964

6065
/** @return a const reference to the guarded mutex
6166
*

include/pthread/mutex.hpp

Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,58 +21,72 @@
2121

2222
namespace pthread {
2323

24-
/** \addtogroup concurrency
25-
*
26-
* @{
27-
*/
28-
class condition_variable;
29-
30-
/** The mutex class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads.
31-
*
32-
* @author herbert koelman
33-
* @date 18/3/2016
34-
*/
35-
class mutex {
36-
37-
friend class condition_variable;
38-
39-
public:
40-
/**
41-
The mutex object is locked (by calling pthread_mutex_lock). If the mutex is already locked, the calling thread blocks until the mutex becomes
42-
available. This operation returns with the mutex object referenced by mutex in the locked state with the calling thread as its owner.
43-
@throw mutex_exception if error conditions preventing this method to succeed.
24+
/** \addtogroup concurrency
25+
*
26+
* @{
4427
*/
45-
void lock ();
4628

47-
/**
48-
The function pthread_mutex_trylock is identical to pthread_mutex_lock except tha
49-
if the mutex object referenced by mutex is currently locked (by any thread,
50-
including the current thread), the call returns immediately.
29+
class condition_variable;
5130

52-
@throw mutex_exception if error conditions preventing this method to succeed.
53-
@see lock
31+
/** The mutex class is a synchronization primitive that can be used to protect shared data from being simultaneously accessed by multiple threads.
32+
*
33+
* @author herbert koelman
34+
* @date 18/3/2016
5435
*/
55-
void try_lock ();
56-
57-
/**
58-
The pthread_mutex_unlock function releases the mutex object referenced by mutex. The manner in which a mutex is released is dependent upon the mutex's type attribute. If there are threads blocked on the mutex object referenced by mutex when unlock is called, resulting in the mutex becoming available, the scheduling policy is used to determine which thread shall acquire the mutex.
59-
@throw mutex_exception if error conditions preventing this method to succeed.
60-
*/
61-
void unlock ();
62-
63-
/*
64-
Constructor/Desctructor
65-
@throw mutex_exception if error conditions preventing this method to succeed.
66-
*/
67-
mutex ();
68-
virtual ~mutex ();
69-
70-
protected:
71-
/** pthread mutex structure */
72-
pthread_mutex_t _mutex;
73-
};
74-
75-
/** @} */
36+
class mutex {
37+
38+
friend class condition_variable;
39+
40+
public:
41+
/**
42+
The mutex object is locked (by calling pthread_mutex_lock). If the mutex is already locked, the calling thread blocks until the mutex becomes
43+
available. This operation returns with the mutex object referenced by mutex in the locked state with the calling thread as its owner.
44+
@throw mutex_exception if error conditions preventing this method to succeed.
45+
*/
46+
void lock();
47+
48+
/**
49+
The function pthread_mutex_trylock is identical to pthread_mutex_lock except tha
50+
if the mutex object referenced by mutex is currently locked (by any thread,
51+
including the current thread), the call returns immediately.
52+
53+
@throw mutex_exception if error conditions preventing this method to succeed.
54+
@see lock
55+
*/
56+
void try_lock();
57+
58+
/**
59+
The pthread_mutex_unlock function releases the mutex object referenced by mutex. The manner in which a mutex is released is dependent upon the mutex's type attribute. If there are threads blocked on the mutex object referenced by mutex when unlock is called, resulting in the mutex becoming available, the scheduling policy is used to determine which thread shall acquire the mutex.
60+
@throw mutex_exception if error conditions preventing this method to succeed.
61+
*/
62+
void unlock();
63+
64+
/**
65+
Constructor/Desctructor
66+
@throw mutex_exception if error conditions preventing this method to succeed.
67+
*/
68+
mutex();
69+
70+
/** not copy-assignable, so no copy contructor is needed.
71+
*
72+
*/
73+
mutex(const mutex &) = delete;
74+
/**
75+
* destroys the mutes (pthread_mutex_destroy)
76+
*/
77+
virtual ~mutex();
78+
79+
/** not copy-assignable
80+
*
81+
*/
82+
void operator=(const mutex &) = delete;
83+
84+
protected:
85+
/** pthread mutex structure */
86+
pthread_mutex_t _mutex;
87+
};
88+
89+
/** @} */
7690

7791
} // namespace pthread
7892

0 commit comments

Comments
 (0)