libzypp: zypp/sat/detail/PoolMember.cc Source File

libzypp 17.38.14

PoolMember.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------*/
9#include "PoolMember.h"
10#include "PoolImpl.h"
11
12namespace zypp::sat::detail {
13
14 static bool & poolDestroyed() {
15 static bool _flag = false; // trivially destructible — never "destroyed"
16 return _flag;
17 }
18
19 static PoolImpl & globalPool()
20 {
21 struct Guard {
22 Guard() = default;
23 Guard(const Guard &) = delete;
24 Guard(Guard &&) = delete;
25 Guard &operator=(const Guard &) = delete;
26 Guard &operator=(Guard &&) = delete;
27 ~Guard() { poolDestroyed() = true; }
28 };
29
30 static PoolImpl _global;
31 static Guard _guard;
32 return _global;
33 }
34
35
37 //
38 // METHOD NAME : PoolMember::myPool
39 // METHOD TYPE : PoolImpl
40 //
41 PoolImpl & PoolMember::myPool()
42 {
43 if ( poolDestroyed () )
44 ZYPP_THROW( zypp::Exception("Global PoolImpl instance used after it was destroyed!") );
45 return globalPool ();
46 }
47
48 bool PoolMember::poolValid()
49 {
50 return !poolDestroyed ();
51 }
52}
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
PoolMember.h
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::sat::detail::PoolImpl
Definition PoolImpl.h:58
zypp::sat::detail
Definition PoolImpl.cc:73
zypp::sat::detail::globalPool
static PoolImpl & globalPool()
Definition PoolMember.cc:19
zypp::sat::detail::poolDestroyed
static bool & poolDestroyed()
Definition PoolMember.cc:14
zypp::sat::operator=
SolvableSpec & operator=(const SolvableSpec &)=default
PoolImpl.h
zypp::sat::detail::PoolMember::myPool
static PoolImpl & myPool()
Definition PoolMember.cc:41
zypp::sat::detail::PoolMember::poolValid
static bool poolValid()
Definition PoolMember.cc:48