V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
microtask.h
1 // Copyright 2018 the V8 project 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 V8_OBJECTS_MICROTASK_H_
6 #define V8_OBJECTS_MICROTASK_H_
7 
8 #include "src/objects.h"
9 
10 // Has to be the last include (doesn't have include guards):
11 #include "src/objects/object-macros.h"
12 
13 namespace v8 {
14 namespace internal {
15 
16 // Abstract base class for all microtasks that can be scheduled on the
17 // microtask queue. This class merely serves the purpose of a marker
18 // interface.
19 class Microtask : public Struct {
20  public:
21  // Dispatched behavior.
22  DECL_CAST(Microtask)
23  DECL_VERIFIER(Microtask)
24 
25  private:
26  DISALLOW_IMPLICIT_CONSTRUCTORS(Microtask);
27 };
28 
29 // A CallbackTask is a special Microtask that allows us to schedule
30 // C++ microtask callbacks on the microtask queue. This is heavily
31 // used by Blink for example.
32 class CallbackTask : public Microtask {
33  public:
34  DECL_ACCESSORS(callback, Foreign)
35  DECL_ACCESSORS(data, Foreign)
36 
37  static const int kCallbackOffset = Microtask::kHeaderSize;
38  static const int kDataOffset = kCallbackOffset + kPointerSize;
39  static const int kSize = kDataOffset + kPointerSize;
40 
41  // Dispatched behavior.
42  DECL_CAST(CallbackTask)
43  DECL_PRINTER(CallbackTask)
44  DECL_VERIFIER(CallbackTask)
45 
46  private:
47  DISALLOW_IMPLICIT_CONSTRUCTORS(CallbackTask)
48 };
49 
50 // A CallableTask is a special (internal) Microtask that allows us to
51 // schedule arbitrary callables on the microtask queue. We use this
52 // for various tests of the microtask queue.
53 class CallableTask : public Microtask {
54  public:
55  DECL_ACCESSORS(callable, JSReceiver)
56  DECL_ACCESSORS2(context, Context)
57 
58  static const int kCallableOffset = Microtask::kHeaderSize;
59  static const int kContextOffset = kCallableOffset + kPointerSize;
60  static const int kSize = kContextOffset + kPointerSize;
61 
62  // Dispatched behavior.
63  DECL_CAST(CallableTask)
64  DECL_PRINTER(CallableTask)
65  DECL_VERIFIER(CallableTask)
66  void BriefPrintDetails(std::ostream& os);
67 
68  private:
69  DISALLOW_IMPLICIT_CONSTRUCTORS(CallableTask);
70 };
71 
72 } // namespace internal
73 } // namespace v8
74 
75 #include "src/objects/object-macros-undef.h"
76 
77 #endif // V8_OBJECTS_MICROTASK_H_
Definition: libplatform.h:13