@@ -21,6 +21,12 @@ namespace
2121{
2222 class LockManagerTestCallbacks : public LockManager ::Callbacks
2323 {
24+ public:
25+ LockManagerTestCallbacks (std::mutex* aMutex = nullptr )
26+ : mutex(aMutex)
27+ {
28+ }
29+
2430 public:
2531 ISC_STATUS getCancelState () const
2632 {
@@ -34,8 +40,18 @@ namespace
3440
3541 void checkoutRun (std::function<void ()> func) const
3642 {
37- func ();
43+ if (mutex)
44+ {
45+ Cleanup lockCleanup ([&]() { mutex->lock (); });
46+ mutex->unlock ();
47+ func ();
48+ }
49+ else
50+ func ();
3851 }
52+
53+ private:
54+ std::mutex* mutex;
3955 };
4056}
4157
@@ -182,7 +198,6 @@ BOOST_AUTO_TEST_CASE(LockUnlockAstTest)
182198 struct ThreadData
183199 {
184200 LockManager* lockManager = nullptr ;
185- std::mutex* globalMutex = nullptr ;
186201 std::mutex localMutex;
187202 std::unordered_map<SLONG, Lock*> locks;
188203 };
@@ -200,7 +215,6 @@ BOOST_AUTO_TEST_CASE(LockUnlockAstTest)
200215 ConfigFile configFile (ConfigFile::USE_TEXT, " \n " );
201216 Config config (configFile);
202217
203- LockManagerTestCallbacks callbacks;
204218 const string lockManagerId (getUniqueId ().c_str ());
205219 auto lockManager = std::make_unique<LockManager>(lockManagerId, &config);
206220
@@ -234,8 +248,8 @@ BOOST_AUTO_TEST_CASE(LockUnlockAstTest)
234248 threads.emplace_back ([&, threadNum]() {
235249 ThreadData threadData;
236250 threadData.lockManager = lockManager.get ();
237- threadData.globalMutex = &globalMutex;
238251
252+ LockManagerTestCallbacks callbacks (&threadData.localMutex );
239253 FbLocalStatus statusVector;
240254 LOCK_OWNER_T ownerId = threadNum + 1 ;
241255 SLONG ownerHandle = 0 ;
0 commit comments