Skip to content

Commit b59207c

Browse files
committed
Added implementation of tbb_hasher for boost::intrusive_ptr.
This allows intrusive_ptr to be used in tbb concurrent unordered containers.
1 parent 07c6b59 commit b59207c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/IECore/RefCounted.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ inline void intrusive_ptr_release( const IECore::RefCounted *r )
169169
r->removeRef();
170170
}
171171

172+
/// Implementation of tbb_hasher to allow intrusive_ptrs to be used
173+
/// with tbb_concurrent_* containers.
174+
template<typename T>
175+
inline size_t tbb_hasher( const boost::intrusive_ptr<T> &ptr )
176+
{
177+
// This is the same as what tbb uses for raw pointers
178+
const size_t h = reinterpret_cast<size_t>( ptr.get() );
179+
return (h >> 3) ^ h;
180+
}
181+
172182
} // namespace IECore
173183

174184

0 commit comments

Comments
 (0)