Sha256: f0406719fd37ecec4ed24dfdd13740207615dffc16d51ab826c6d9d401939869

Contents?: true

Size: 856 Bytes

Versions: 16

Compression:

Stored size: 856 Bytes

Contents

#include <leatherman/util/scope_exit.hpp>

using namespace std;

namespace leatherman { namespace util {

    scope_exit::scope_exit()
    {
    }

    scope_exit::scope_exit(function<void()> callback) :
        _callback(callback)
    {
    }

    scope_exit::scope_exit(scope_exit&& other)
    {
        *this = std::move(other);
    }

    scope_exit& scope_exit::operator=(scope_exit&& other)
    {
        _callback = std::move(other._callback);

        // Ensure the callback is in a known "empty" state; we can't rely on default move semantics for that
        other._callback = nullptr;
        return *this;
    }

    scope_exit::~scope_exit()
    {
        invoke();
    }

    void scope_exit::invoke()
    {
        if (_callback) {
            _callback();
            _callback = nullptr;
        }
    }

}}  // namespace leatherman::util

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.12.1.cfacter.20181031 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.11.6.cfacter.20181031 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.12.1.cfacter.20181023 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.11.5.cfacter.20181022 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.12.0.cfacter.20181004 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.12.0.cfacter.20181001 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.12.0.cfacter.20180918 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.11.4.cfacter.20180821 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.11.3.cfacter.20180716 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.11.2.cfacter.20180612 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.9.6.cfacter.20180612 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.11.2.cfacter.20180606 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.9.6.cfacter.20180606 ext/facter/leatherman/util/src/scope_exit.cc
facter-3.11.0.cfacter.20180319 ext/facter/leatherman/util/src/scope_exit.cc
cfacter-3.11.0.rc.20180314 ext/facter/leatherman/util/src/scope_exit.cc