text: // Copyright (c) 2019-2021 Fango Developers
  // Copyright (c) 2018-2021 Fandom Gold Society
  // Copyright (c) 2018-2019 Conceal Network & Conceal Devs
  // Copyright (c) 2016-2019 The Karbowanec developers
  // Copyright (c) 2012-2018 The CryptoNote developers
  //
  // This file is part of Fango.
  //
  // Fango is free & open source software distributed in the hope 
  // that it will be useful, but WITHOUT ANY WARRANTY; without even
  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  // PURPOSE. You may redistribute it and/or modify it under the terms
  // of the GNU General Public License v3 or later versions as published
  // by the Free Software Foundation. Fango includes elements written 
  // by third parties. See file labeled LICENSE for more details.
  // You should have received a copy of the GNU General Public License
  // along with Fango. If not, see <https://www.gnu.org/licenses/>.
  
  #include "ScopeExit.h"
  
  namespace Tools {
  
  ScopeExit::ScopeExit(std::function<void()>&& handler) :
    m_handler(std::move(handler)),
    m_cancelled(false) {
  }
  
  ScopeExit::~ScopeExit() {
    if (!m_cancelled) {
      m_handler();
    }
  }
  
  void ScopeExit::cancel() {
    m_cancelled = true;
  }
  
  }
  