123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #ifndef BASE_ONE_SHOT_EVENT_H_
- #define BASE_ONE_SHOT_EVENT_H_
- #include <vector>
- #include "base/callback_forward.h"
- #include "base/logging.h"
- #include "base/memory/ref_counted.h"
- #include "base/memory/weak_ptr.h"
- #include "base/threading/thread_checker.h"
- #include "base/threading/thread_task_runner_handle.h"
- namespace base {
- class Location;
- class SingleThreadTaskRunner;
- class TimeDelta;
- class BASE_EXPORT OneShotEvent {
- public:
- OneShotEvent();
-
-
-
-
- explicit OneShotEvent(bool signaled);
- ~OneShotEvent();
-
-
-
- bool is_signaled() const {
- DCHECK(thread_checker_.CalledOnValidThread());
- return signaled_;
- }
-
-
-
-
- void Signal();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void Post(const Location& from_here,
- OnceClosure task,
- scoped_refptr<SingleThreadTaskRunner> runner =
- ThreadTaskRunnerHandle::Get()) const;
- void PostDelayed(const Location& from_here,
- OnceClosure task,
- const TimeDelta& delay) const;
- private:
- struct TaskInfo;
- void PostImpl(const Location& from_here,
- OnceClosure task,
- scoped_refptr<SingleThreadTaskRunner> runner,
- const TimeDelta& delay) const;
- ThreadChecker thread_checker_;
- bool signaled_;
-
-
-
-
-
-
-
-
-
- mutable std::vector<TaskInfo> tasks_;
- };
- }
- #endif
|