00001 #ifndef ARTDAQ_CORE_UTILITIES_TRACELOCK
00002 #define ARTDAQ_CORE_UTILITIES_TRACELOCK_HH 1
00003
00004 #include "tracemf.h"
00005 #include <mutex>
00006
00010 class TraceLock {
00011 public:
00018 TraceLock(std::mutex& mutex,int level, std::string description);
00019
00023 virtual ~TraceLock();
00024
00025 private:
00026 std::unique_lock<std::mutex> lock_;
00027 std::string description_;
00028 int level_;
00029 };
00030
00031 inline TraceLock::TraceLock(std::mutex& mutex,int level, std::string description)
00032 : lock_(mutex)
00033 , description_(description)
00034 , level_(level)
00035 {
00036 TLOG_ARB(level_, "TraceLock") << "Acquired Lock " << description_ << ", mutex=" << (void*)&mutex << ", lock=" << (void*)&lock_ ;
00037 }
00038
00039 inline TraceLock::~TraceLock() {
00040 TLOG_ARB(level_, "TraceLock") << "Releasing lock " << description_ << ", lock=" << (void*)&lock_ ;
00041 }
00042
00043 #endif
00044