fix weakmap/set lock delegation
This commit is contained in:
@ -257,6 +257,13 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//! Access to the weak_set internal lock
|
||||
//! for use with batch operations.
|
||||
//! @warning Use caution when swap()ing while holding this lock!
|
||||
inline epicsMutex& mutex() const {
|
||||
return m_data->mutex;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // WEAKMAP_H
|
||||
|
@ -191,8 +191,8 @@ public:
|
||||
//! Access to the weak_set internal lock
|
||||
//! for use with batch operations.
|
||||
//! @warning Use caution when swap()ing while holding this lock!
|
||||
inline guard_type lock() const {
|
||||
return guard_type(m_data->mutex);
|
||||
inline epicsMutex& mutex() const {
|
||||
return m_data->mutex;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -150,6 +150,21 @@ void testWeakMap2()
|
||||
testOk1(!!ptr);
|
||||
}
|
||||
|
||||
static
|
||||
void testWeakLock()
|
||||
{
|
||||
typedef weak_value_map<int,int> map_type;
|
||||
map_type::value_pointer ptr;
|
||||
map_type map;
|
||||
|
||||
{
|
||||
map_type::guard_type G(map.mutex());
|
||||
|
||||
ptr.reset(new int(42));
|
||||
map[4] = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MAIN(testweak)
|
||||
@ -160,5 +175,6 @@ MAIN(testweak)
|
||||
testWeakSetInvalid();
|
||||
testWeakMap1();
|
||||
testWeakMap2();
|
||||
testWeakLock();
|
||||
return testDone();
|
||||
}
|
||||
|
Reference in New Issue
Block a user