Public Member Functions | Private Attributes | List of all members
cet::sqlite::ConnectionFactory Class Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/cetlib/v3_06_01/source/cetlib/sqlite/ConnectionFactory.h"

Public Member Functions

template<typename DatabaseOpenPolicy = detail::DefaultDatabaseOpenPolicy, typename... PolicyArgs>
auto make (std::string const &file_name, PolicyArgs &&...) -> Connection
 
template<typename DatabaseOpenPolicy , typename... PolicyArgs>
auto make (std::string const &filename, PolicyArgs &&...policyArgs) -> Connection
 

Private Attributes

std::map< std::string, std::weak_ptr< std::mutex > > databaseLocks_
 
std::mutex mutex_
 

Detailed Description

Definition at line 42 of file ConnectionFactory.h.

Member Function Documentation

template<typename DatabaseOpenPolicy = detail::DefaultDatabaseOpenPolicy, typename... PolicyArgs>
auto cet::sqlite::ConnectionFactory::make ( std::string const &  file_name,
PolicyArgs &&  ... 
) -> Connection
template<typename DatabaseOpenPolicy , typename... PolicyArgs>
auto cet::sqlite::ConnectionFactory::make ( std::string const &  filename,
PolicyArgs &&...  policyArgs 
) -> Connection

Definition at line 58 of file ConnectionFactory.h.

References databaseLocks_, shutoffs::filename, m, and mutex_.

60 {
61  // Implementation a la Herb Sutter's favorite 10-liner
62  std::lock_guard<decltype(mutex_)> hold{mutex_};
63  auto m = databaseLocks_[filename].lock();
64  if (!m) {
65  databaseLocks_[filename] = m = std::make_shared<std::mutex>();
66  }
67  return Connection{
68  filename, m, DatabaseOpenPolicy{std::forward<PolicyArgs>(policyArgs)...}};
69 }
std::map< std::string, std::weak_ptr< std::mutex > > databaseLocks_
string filename
Definition: shutoffs.py:106

Member Data Documentation

std::map<std::string, std::weak_ptr<std::mutex> > cet::sqlite::ConnectionFactory::databaseLocks_
private

Definition at line 49 of file ConnectionFactory.h.

Referenced by make().

std::mutex cet::sqlite::ConnectionFactory::mutex_
private

Definition at line 50 of file ConnectionFactory.h.

Referenced by make().


The documentation for this class was generated from the following file: