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

Side by Side Diff: include/v8.h

Issue 1741893003: Introduce v8::MicrotasksScope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: SetAutorunMicrotasks fix Created 4 years, 9 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
« no previous file with comments | « no previous file | src/api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 5041 matching lines...) Expand 10 before | Expand all | Expand 10 after
5052 Local<Value> value_; 5052 Local<Value> value_;
5053 Local<StackTrace> stack_trace_; 5053 Local<StackTrace> stack_trace_;
5054 }; 5054 };
5055 5055
5056 typedef void (*PromiseRejectCallback)(PromiseRejectMessage message); 5056 typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
5057 5057
5058 // --- Microtasks Callbacks --- 5058 // --- Microtasks Callbacks ---
5059 typedef void (*MicrotasksCompletedCallback)(Isolate*); 5059 typedef void (*MicrotasksCompletedCallback)(Isolate*);
5060 typedef void (*MicrotaskCallback)(void* data); 5060 typedef void (*MicrotaskCallback)(void* data);
5061 5061
5062
5063 /**
5064 * Policy for running microtasks:
5065 * - explicit: microtasks are invoked with Isolate::RunMicrotasks() method;
5066 * - scoped: microtasks invocation is controlled by MicrotasksScope objects;
5067 * - auto: microtasks are invoked when the script call depth decrements
5068 * to zero.
5069 */
5070 enum class MicrotasksPolicy { kExplicit, kScoped, kAuto };
5071
5072
5073 /**
5074 * This scope is used to control microtasks when kScopeMicrotasksInvocation
5075 * is used on Isolate. In this mode every non-primitive call to V8 should be
5076 * done inside some MicrotasksScope.
5077 * Microtasks are executed when topmost MicrotasksScope marked as kRunMicrotasks
5078 * exits.
5079 * kDoNotRunMicrotasks should be used to annotate calls not intended to trigger
5080 * microtasks.
5081 */
5082 class V8_EXPORT MicrotasksScope {
5083 public:
5084 enum Type { kRunMicrotasks, kDoNotRunMicrotasks };
5085
5086 MicrotasksScope(Isolate* isolate, Type type);
5087 ~MicrotasksScope();
5088
5089 /**
5090 * Runs microtasks if no kRunMicrotasks scope is currently active.
5091 */
5092 static void PerformCheckpoint(Isolate* isolate);
5093
5094 /**
5095 * Returns current depth of nested kRunMicrotasks scopes.
5096 */
5097 static int GetCurrentDepth(Isolate* isolate);
5098
5099 private:
5100 internal::Isolate* const isolate_;
5101 bool run_;
5102
5103 // Prevent copying.
5104 MicrotasksScope(const MicrotasksScope&);
5105 MicrotasksScope& operator=(const MicrotasksScope&);
5106 };
5107
5108
5062 // --- Failed Access Check Callback --- 5109 // --- Failed Access Check Callback ---
5063 typedef void (*FailedAccessCheckCallback)(Local<Object> target, 5110 typedef void (*FailedAccessCheckCallback)(Local<Object> target,
5064 AccessType type, 5111 AccessType type,
5065 Local<Value> data); 5112 Local<Value> data);
5066 5113
5067 // --- AllowCodeGenerationFromStrings callbacks --- 5114 // --- AllowCodeGenerationFromStrings callbacks ---
5068 5115
5069 /** 5116 /**
5070 * Callback to check if code generation from strings is allowed. See 5117 * Callback to check if code generation from strings is allowed. See
5071 * Context::AllowCodeGenerationFromStrings. 5118 * Context::AllowCodeGenerationFromStrings.
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
5877 /** 5924 /**
5878 * Experimental: Enqueues the callback to the Microtask Work Queue 5925 * Experimental: Enqueues the callback to the Microtask Work Queue
5879 */ 5926 */
5880 void EnqueueMicrotask(Local<Function> microtask); 5927 void EnqueueMicrotask(Local<Function> microtask);
5881 5928
5882 /** 5929 /**
5883 * Experimental: Enqueues the callback to the Microtask Work Queue 5930 * Experimental: Enqueues the callback to the Microtask Work Queue
5884 */ 5931 */
5885 void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL); 5932 void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL);
5886 5933
5887 /** 5934 /**
5888 * Experimental: Controls whether the Microtask Work Queue is automatically 5935 * Experimental: Controls how Microtasks are invoked. See MicrotasksPolicy
5889 * run when the script call depth decrements to zero. 5936 * for details.
5890 */ 5937 */
5891 void SetAutorunMicrotasks(bool autorun); 5938 void SetMicrotasksPolicy(MicrotasksPolicy policy);
5939 V8_DEPRECATE_SOON("Use SetMicrotasksPolicy",
5940 void SetAutorunMicrotasks(bool autorun));
5892 5941
5893 /** 5942 /**
5894 * Experimental: Returns whether the Microtask Work Queue is automatically 5943 * Experimental: Returns the policy controlling how Microtasks are invoked.
5895 * run when the script call depth decrements to zero.
5896 */ 5944 */
5897 bool WillAutorunMicrotasks() const; 5945 MicrotasksPolicy GetMicrotasksPolicy() const;
5946 V8_DEPRECATE_SOON("Use GetMicrotasksPolicy",
5947 bool WillAutorunMicrotasks() const);
5898 5948
5899 /** 5949 /**
5900 * Experimental: adds a callback to notify the host application after 5950 * Experimental: adds a callback to notify the host application after
5901 * microtasks were run. The callback is triggered by explicit RunMicrotasks 5951 * microtasks were run. The callback is triggered by explicit RunMicrotasks
5902 * call or automatic microtasks execution (see SetAutorunMicrotasks). 5952 * call or automatic microtasks execution (see SetAutorunMicrotasks).
5903 * 5953 *
5904 * Callback will trigger even if microtasks were attempted to run, 5954 * Callback will trigger even if microtasks were attempted to run,
5905 * but the microtasks queue was empty and no single microtask was actually 5955 * but the microtasks queue was empty and no single microtask was actually
5906 * executed. 5956 * executed.
5907 * 5957 *
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after
8592 */ 8642 */
8593 8643
8594 8644
8595 } // namespace v8 8645 } // namespace v8
8596 8646
8597 8647
8598 #undef TYPE_CHECK 8648 #undef TYPE_CHECK
8599 8649
8600 8650
8601 #endif // INCLUDE_V8_H_ 8651 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698