ConnectionFactory.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
4 using namespace cet::sqlite;
5 
8 {
9  // Implementation a la Herb Sutter's favorite 10-liner
10  hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
11  // Note: Convert the weak_ptr to a shared_ptr using the member
12  // function lock(), this is not an operation on the mutex.
13  auto shared_ptr_to_mutex = databaseLocks_[filename].lock();
14  if (!shared_ptr_to_mutex) {
15  using namespace std::string_literals;
16  databaseLocks_[filename] = shared_ptr_to_mutex =
17  std::make_shared<hep::concurrency::RecursiveMutex>(
18  "ConnectionFactory::databaseLocks_["s + filename + "]"s);
19  }
20  auto ret = new Connection{filename, shared_ptr_to_mutex};
21  return ret;
22 }
std::string string
Definition: nybbler.cc:12
string filename
Definition: train.py:213
hep::concurrency::RecursiveMutex mutex_
std::map< std::string, std::weak_ptr< hep::concurrency::RecursiveMutex > > databaseLocks_
auto make_connection(std::string const &file_name, PolicyArgs &&...) -> Connection *
static QCString * s
Definition: config.cpp:1042