Skip to content

Commit

Permalink
Fix for a build problem in ThreadSafeFunctor::operator bool()
Browse files Browse the repository at this point in the history
  • Loading branch information
julianstorer committed Dec 3, 2024
1 parent 2d58413 commit 348802f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/choc_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -2874,7 +2874,9 @@ inline void testThreading (choc::test::TestProgress& progress)
choc::threading::ThreadSafeFunctor<std::function<void(int)>> tsf;

int result = 0;
CHOC_EXPECT_FALSE (tsf);
tsf = [&] (int x) { result = x; };
CHOC_EXPECT_TRUE (tsf);
CHOC_EXPECT_TRUE (tsf (2));
tsf.reset();
CHOC_EXPECT_FALSE (tsf (3));
Expand Down
2 changes: 1 addition & 1 deletion threading/choc_ThreadSafeFunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ template <typename FunctionType>
ThreadSafeFunctor<FunctionType>::operator bool() const
{
std::scoped_lock l (callback->lock);
return callback->fn;
return callback->fn != nullptr;
}

template <typename FunctionType>
Expand Down

0 comments on commit 348802f

Please sign in to comment.