Skip to content

Commit 2693cb6

Browse files
author
Herbert Koelman
committed
fixes #65
tested on AIX
1 parent cd8c0de commit 2693cb6

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

include/pthread/lock_guard.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ namespace pthread {
4747
*
4848
* @param m reference to a valid pthread::mutex
4949
*/
50-
explicit lock_guard(MutexType &m): _mutex(&m) {
51-
_mutex->lock();
50+
explicit lock_guard(MutexType &m){ //: _mutex(&m) {
51+
_mutex = &m ;
52+
_mutex->lock();
5253
}
5354

5455
/** The destructor release the guarded mutex.

include/pthread/sync_queue.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,23 @@ namespace pthread {
8080
}
8181

8282
/** @return current number of elements in the queue */
83-
size_t size() const {
8483
#if __cplusplus < 201103L
84+
size_t size() const {
8585
// we use read/write locks when std::atomic is not available
8686
pthread::lock_guard<pthread::read_lock> lck(_rwlock);
87+
#else
88+
size_t size() const {
8789
#endif
8890
return _items.size();
8991
}
9092

9193
/** @return maximun number of items that can be put in the queue */
92-
size_t max_size() const {
9394
#if __cplusplus < 201103L
95+
size_t max_size() {
9496
// we use read/write locks when std::atomic is not available
9597
pthread::lock_guard<pthread::read_lock> lck(_rwlock);
98+
#else
99+
size_t max_size() const {
96100
#endif
97101
return _max_size ;
98102
}

tests/synchronized_queue_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <memory>
1010
#include <ctime>
1111

12-
#define MESSAGES_TO_PRODUCE 10 //500000 // messages produced
12+
#define MESSAGES_TO_PRODUCE 5000 // messages produced
1313
#define CONSUMER_PROCESSING_DURATION 20 // millis
1414

1515
#define CONSUMERS 10 // number of consumer threads

0 commit comments

Comments
 (0)