Browse Source

Moved: module 'call_with_lock' to libpEpCxx11

pull/15/head
heck 3 years ago
parent
commit
2a45adcb40
  1. 8
      src/call_with_lock.cc
  2. 26
      src/call_with_lock.hh

8
src/call_with_lock.cc

@ -1,8 +0,0 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#include "call_with_lock.hh"
namespace pEp {
std::mutex call_with_lock_mutex;
}

26
src/call_with_lock.hh

@ -1,26 +0,0 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#ifndef LIBPEPADAPTER_CALL_WITH_LOCK_HH
#define LIBPEPADAPTER_CALL_WITH_LOCK_HH
#include <mutex>
namespace pEp {
extern std::mutex call_with_lock_mutex;
// TODO: use && and std::forward<> to avoid copying of the arguments.
// It is not relevant, yet, because at the moment we use this function
// template only for init() and release() which have cheap-to-copy pointer
// parameters only
template<class R, class... Args>
R call_with_lock(R (*fn)(Args...), Args... args)
{
std::lock_guard<std::mutex> L(call_with_lock_mutex);
return fn(args...);
}
} // namespace pEp
#endif // LIBPEPADAPTER_CALL_WITH_LOCK_HH
Loading…
Cancel
Save