- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Lot of times, when we do template meta programming, we need to provide some containers with no mutex( tbb containers ) and some containers with a tbb Mutex (Boost /std containers). The Scoped Lock feature makes the code different for both. If we can have a NullMutex feature like the one available in ACE( ACE_Null_Mutex), it would be easy to handle such situations. Please advise me on any work arounds currently available.This NullMutex is more like a no-op.
Thanks in advance,
Gokul.
Lot of times, when we do template meta programming, we need to provide some containers with no mutex( tbb containers ) and some containers with a tbb Mutex (Boost /std containers). The Scoped Lock feature makes the code different for both. If we can have a NullMutex feature like the one available in ACE( ACE_Null_Mutex), it would be easy to handle such situations. Please advise me on any work arounds currently available.This NullMutex is more like a no-op.
Thanks in advance,
Gokul.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you only use scoped lock pattern (i.e. no explicit calls to acquire/release), the following should work:
[cpp]class null_mutex { //! Deny assignment and copy construction
null_mutex( const null_mutex& ); void operator=( const null_mutex& ); public: class scoped_lock { public: scoped_lock( null_mutex& ) {} ~scoped_lock() { } }; // Mutex traits static const bool is_rw_mutex = false; static const bool is_recursive_mutex = false; static const bool is_fair_mutex = false; }; [/cpp]
Anyway the idea is reasonable. Thanks for the suggestion.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you only use scoped lock pattern (i.e. no explicit calls to acquire/release), the following should work:
[cpp]class null_mutex { //! Deny assignment and copy construction
null_mutex( const null_mutex& ); void operator=( const null_mutex& ); public: class scoped_lock { public: scoped_lock( null_mutex& ) {} ~scoped_lock() { } }; // Mutex traits static const bool is_rw_mutex = false; static const bool is_recursive_mutex = false; static const bool is_fair_mutex = false; }; [/cpp]
Anyway the idea is reasonable. Thanks for the suggestion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Alexey Kukanov (Intel)
If you only use scoped lock pattern (i.e. no explicit calls to acquire/release), the following should work:
[cpp]class null_mutex {
//! Deny assignment and copy construction
null_mutex( const null_mutex& );
void operator=( const null_mutex& );
public:
class scoped_lock {
public:
scoped_lock( null_mutex& ) {}
~scoped_lock() { }
};
// Mutex traits
static const bool is_rw_mutex = false;
static const bool is_recursive_mutex = false;
static const bool is_fair_mutex = false;
};
[/cpp]
Anyway the idea is reasonable. Thanks for the suggestion.
Gokul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We willmake an extended version of it part of TBB.
Also during the internal discussion, it was suggested that is_recursive and is_fair traits should be true for null_mutex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Alexey Kukanov (Intel)
We willmake an extended version of it part of TBB.
Also during the internal discussion, it was suggested that is_recursive and is_fair traits should be true for null_mutex.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page