- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
As you probably know, Boost.Thread provides a number of generic lock scope guard classes, such as lock_guard< T >,unique_lock< T >,shared_lock< T >,upgrade_lock< T > andupgrade_to_unique_lock< T >, where T is a lockable type. These classes assume presence of the specific member functions in T to perform locking, but some of these functions are not present in TBB mutexes. My current problem is withspin_rw_mutex, which does support shared and upgradable locking but with a different interface. Other TBB mutex types also provide locking with different interfaces, and what's most frustrating is that different mutex types provide same locking functionality through different interfaces (e.g. queueing mutexes have no methods at all).
Could it be done that all TBB mutexes provide the same interface for each particular type of locking, preferably compatible with Boost locks? I realize that in case of queueing mutexes this would not be trivial, I can only think of specializing lock types for these mutexes. These specializations could be placed in a separate header withing compat directory. For other mutexes it seems to suffice to add the required synonym methods for the existing ones (e.g. lock_shared forwarding to lock_read inspin_rw_mutex).
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No comments about this? I could submit a patch if there is interest, but I'd like to know beforehand before I start working on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What would be the purpose?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I thought it was obvious from my original post. I want to be able to use Boost locks with TBB mutexes. Aside from simplifying generic programming, Boost locks provide other features, such as move support, that I often use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's rather vague, I'm afraid. It does surprise that boost does not seem to provide a spin mutex (I just had a look at the documentation), but wouldn't an adapter be fairly trivial to write? I guess if you need it, you'll write it, and then the code will explain itself, even if it's not comprehensive yet.
Be aware, though, thatlocks are often not the best way to synchronise tasks (except very briefly), and they will sometimes lead to deadlock because of how the TBB schedules tasks, so it may be better to express additional task dependencies instead.
Be aware, though, thatlocks are often not the best way to synchronise tasks (except very briefly), and they will sometimes lead to deadlock because of how the TBB schedules tasks, so it may be better to express additional task dependencies instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Of course, I could write wrappers around different TBB mutexes to unify their interfaces, in fact this is what I do, currently. It just seems to me that the need for such scaffolding indicate that the interface of the library is flawed.
BTW, I don't use TBB solely for its task scheduling mechanism. In fact, most of my use cases only involve concurrent containers and mutexes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Whether it's flawed (and which side...) or justdifferent, without details I'll have to abstain from further discussion.
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