1// Copyright 2014 The Chromium Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#import <UIKit/UIKit.h> 6 7#include <string_view> 8 9#include "base/critical_closure.h" 10 11namespace base::internal { 12 13ImmediateCriticalClosure::ImmediateCriticalClosure(std::string_view task_name, 14 OnceClosure closure) 15 : critical_action_(task_name), closure_(std::move(closure)) { 16 CHECK(!closure_.is_null()); 17} 18 19ImmediateCriticalClosure::~ImmediateCriticalClosure() {} 20 21void ImmediateCriticalClosure::Run() { 22 CHECK(!closure_.is_null()); 23 std::move(closure_).Run(); 24} 25 26PendingCriticalClosure::PendingCriticalClosure(std::string_view task_name, 27 OnceClosure closure) 28 : task_name_(task_name), closure_(std::move(closure)) { 29 CHECK(!closure_.is_null()); 30} 31 32PendingCriticalClosure::~PendingCriticalClosure() {} 33 34void PendingCriticalClosure::Run() { 35 CHECK(!closure_.is_null()); 36 critical_action_.emplace(task_name_); 37 std::move(closure_).Run(); 38} 39 40} // namespace base::internal 41