chromium/base/one_shot_event.h

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_ONE_SHOT_EVENT_H_
#define BASE_ONE_SHOT_EVENT_H_

#include <vector>

#include "base/base_export.h"
#include "base/check.h"
#include "base/functional/callback_forward.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"

namespace base {

class Location;
class TimeDelta;

// This class represents an event that's expected to happen once. It allows
// clients to guarantee that code is run after the `OneShotEvent` is signaled.
// If the `OneShotEvent` is destroyed before it's signaled, the closures are
// destroyed without being run.
//
// This class is similar to a `WaitableEvent` combined with several
// `WaitableEventWatcher`s, but using it is simpler.
//
// This class' methods must be used from a single sequence (although not
// necessarily the one in which it has been constructed).
// However, there are no restrictions on the `TaskRunner`s used - and hence, the
// sequence/thread on which the posted tasks will run. By default they will
// be posted to the current sequence's default task runner.
class BASE_EXPORT OneShotEvent {};

}  // namespace base

#endif  // BASE_ONE_SHOT_EVENT_H_