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

Side by Side Diff: include/v8.h

Issue 1762943002: Revert of Introduce v8::MicrotasksScope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
5109 // --- Failed Access Check Callback --- 5062 // --- Failed Access Check Callback ---
5110 typedef void (*FailedAccessCheckCallback)(Local<Object> target, 5063 typedef void (*FailedAccessCheckCallback)(Local<Object> target,
5111 AccessType type, 5064 AccessType type,
5112 Local<Value> data); 5065 Local<Value> data);
5113 5066
5114 // --- AllowCodeGenerationFromStrings callbacks --- 5067 // --- AllowCodeGenerationFromStrings callbacks ---
5115 5068
5116 /** 5069 /**
5117 * Callback to check if code generation from strings is allowed. See 5070 * Callback to check if code generation from strings is allowed. See
5118 * Context::AllowCodeGenerationFromStrings. 5071 * Context::AllowCodeGenerationFromStrings.
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
5924 /** 5877 /**
5925 * Experimental: Enqueues the callback to the Microtask Work Queue 5878 * Experimental: Enqueues the callback to the Microtask Work Queue
5926 */ 5879 */
5927 void EnqueueMicrotask(Local<Function> microtask); 5880 void EnqueueMicrotask(Local<Function> microtask);
5928 5881
5929 /** 5882 /**
5930 * Experimental: Enqueues the callback to the Microtask Work Queue 5883 * Experimental: Enqueues the callback to the Microtask Work Queue
5931 */ 5884 */
5932 void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL); 5885 void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL);
5933 5886
5934 /** 5887 /**
5935 * Experimental: Controls how Microtasks are invoked. See MicrotasksPolicy 5888 * Experimental: Controls whether the Microtask Work Queue is automatically
5936 * for details. 5889 * run when the script call depth decrements to zero.
5937 */ 5890 */
5938 void SetMicrotasksPolicy(MicrotasksPolicy policy); 5891 void SetAutorunMicrotasks(bool autorun);
5939 V8_DEPRECATE_SOON("Use SetMicrotasksPolicy",
5940 void SetAutorunMicrotasks(bool autorun));
5941 5892
5942 /** 5893 /**
5943 * Experimental: Returns the policy controlling how Microtasks are invoked. 5894 * Experimental: Returns whether the Microtask Work Queue is automatically
5895 * run when the script call depth decrements to zero.
5944 */ 5896 */
5945 MicrotasksPolicy GetMicrotasksPolicy() const; 5897 bool WillAutorunMicrotasks() const;
5946 V8_DEPRECATE_SOON("Use GetMicrotasksPolicy",
5947 bool WillAutorunMicrotasks() const);
5948 5898
5949 /** 5899 /**
5950 * Experimental: adds a callback to notify the host application after 5900 * Experimental: adds a callback to notify the host application after
5951 * microtasks were run. The callback is triggered by explicit RunMicrotasks 5901 * microtasks were run. The callback is triggered by explicit RunMicrotasks
5952 * call or automatic microtasks execution (see SetAutorunMicrotasks). 5902 * call or automatic microtasks execution (see SetAutorunMicrotasks).
5953 * 5903 *
5954 * Callback will trigger even if microtasks were attempted to run, 5904 * Callback will trigger even if microtasks were attempted to run,
5955 * but the microtasks queue was empty and no single microtask was actually 5905 * but the microtasks queue was empty and no single microtask was actually
5956 * executed. 5906 * executed.
5957 * 5907 *
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after
8642 */ 8592 */
8643 8593
8644 8594
8645 } // namespace v8 8595 } // namespace v8
8646 8596
8647 8597
8648 #undef TYPE_CHECK 8598 #undef TYPE_CHECK
8649 8599
8650 8600
8651 #endif // INCLUDE_V8_H_ 8601 #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