|
Boost : |
Subject: Re: [boost] [log] Release candidate 1
From: Stefan Strasser (strasser_at_[hidden])
Date: 2013-03-11 08:27:14
Am 11.03.2013 12:51, schrieb Andrey Semashev:
>> then it's an implemention detail, I'd suggest making all the functions of
>> logging::core static, or make logging::core a namespace.
>> if you wanna add the feature you've mentioned later on, you could for
>> example ask the user to construct and hold a core::log_during_termination
>> object, which - again as an implementation detail - holds a shared_ptr to
>> the internal core.
>
> This won't work because every static function would have to obtain the
> pointer to the core which may be invalidated because its global
> destructor has been invoked already.
I'm not suggesting any changes to the internals, only to the interface.
Maybe the following code makes it a little clearer:
class core{
public:
static void set_filter(){ get()->set_filter_impl(); }
private:
static shared_ptr<core> get();
void set_filter_impl();
friend class log_during_termination;
};
class log_during_termination{
public:
log_during_termination() : hold(core::get()){}
private:
shared_ptr<core> hold;
};
user code:
-----------
A(){
public:
~A(){
//logging core is not destructed yet
}
private:
log::log_during_termination logterm;
}
static A a;
Best regards
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk