Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: components/scheduler/promises/promise_executor.h

Issue 1401553002: NOT INTENDED FOR LANDING: A promises demo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Support for rejectatble promises! Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_SCHEDULER_PROMISES_PROMISE_EXECUTOR_H_
6 #define COMPONENTS_SCHEDULER_PROMISES_PROMISE_EXECUTOR_H_
7
8 #include <set>
9
10 #include "base/macros.h"
11 #include "components/scheduler/promises/promise.h"
12 #include "components/scheduler/scheduler_export.h"
13
14 namespace promise {
15 namespace internal {
16
17 class SCHEDULER_EXPORT PromiseExecutor {
18 public:
19 PromiseExecutor();
20 virtual ~PromiseExecutor();
21
22 template <typename R>
23 void StartResolve(::promise::Promise<R>& promise) {
24 StartResolveInternal(promise.promise());
25 }
26
27 virtual void StartResolveInternal(internal::PromiseBase* promise);
28
29 // Returns true if some work was done.
30 bool ResolveOnePromise();
31
32 // Note this blocks.
33 void RunUntilIdle();
34
35 protected:
36 friend class PromiseBase;
37
38 PromiseBase* GetNextReadyPromise();
39 void ResolvePromise(PromiseBase* promise);
40
41 // Returns true if resolving |promise| means we can resolve more work.
42 virtual bool OnPromiseResolved(PromiseBase* promise);
43
44 // Returns true if rejecting |promise| means we can can run a reject callback.
45 virtual bool OnPromiseRejected(PromiseBase* promise);
46
47 std::set<PromiseBase*> eager_ready_set_;
48 std::set<PromiseBase*> lazy_ready_set_;
49 PromiseBase* cursor_;
50
51 DISALLOW_COPY_AND_ASSIGN(PromiseExecutor);
52 };
53
54 } // namespace internal
55 } // namespace promise
56
57 #endif // COMPONENTS_SCHEDULER_PROMISES_PROMISE_EXECUTOR_H_
OLDNEW
« no previous file with comments | « components/scheduler/promises/promise.cc ('k') | components/scheduler/promises/promise_executor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698