提交 7d063ff7 编写于 作者: M Matt Pharr

ThreadLocal::Get(): hold reader-writer mutex before calling the callback.

This allows users to not need to worry about thread safety in their
callback implementations. In particular, this fixes a race in the
BVHAggregate's use of ThreadLocal that rarely led to crashes or complaints
about malloc heap corruption during BVH construction.
上级 21115e81
......@@ -78,8 +78,11 @@ inline T &ThreadLocal<T>::Get() {
return threadLocal;
} else if (!hashTable[hash]) {
mutex.unlock_shared();
T newItem = create();
// Get reader-writer lock before calling the callback so that the user
// doesn't have to worry about writing a thread-safe callback.
mutex.lock();
T newItem = create();
if (hashTable[hash]) {
// someone else got there first--keep looking, but now
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册