libzypp 17.38.6
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
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 //
42 {
43 if ( poolDestroyed () )
44 ZYPP_THROW( zypp::Exception("Global PoolImpl instance used after it was destroyed!") );
45 return globalPool ();
46 }
47
49 {
50 return !poolDestroyed ();
51 }
52}
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
Base class for Exception.
Definition Exception.h:153
static PoolImpl & globalPool()
Definition PoolMember.cc:19
static bool & poolDestroyed()
Definition PoolMember.cc:14
SolvableSpec & operator=(const SolvableSpec &)=default
static PoolImpl & myPool()
Definition PoolMember.cc:41