GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/req_wrap.h Lines: 2 2 100.0 %
Date: 2019-09-17 22:33:17 Branches: 1 2 50.0 %

Line Branch Exec Source
1
#ifndef SRC_REQ_WRAP_H_
2
#define SRC_REQ_WRAP_H_
3
4
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
6
#include "async_wrap.h"
7
#include "env.h"
8
#include "util.h"
9
#include "v8.h"
10
11
namespace node {
12
13
class ReqWrapBase {
14
 public:
15
  explicit inline ReqWrapBase(Environment* env);
16
17
114026
  virtual ~ReqWrapBase() = default;
18
19
  virtual void Cancel() = 0;
20
  virtual AsyncWrap* GetAsyncWrap() = 0;
21
22
 private:
23
  friend int GenDebugSymbols();
24
  friend class Environment;
25
26
  ListNode<ReqWrapBase> req_wrap_queue_;
27
};
28
29
template <typename T>
30
class ReqWrap : public AsyncWrap, public ReqWrapBase {
31
 public:
32
  inline ReqWrap(Environment* env,
33
                 v8::Local<v8::Object> object,
34
                 AsyncWrap::ProviderType provider);
35
  inline ~ReqWrap() override;
36
  // Call this after the req has been dispatched, if that did not already
37
  // happen by using Dispatch().
38
  inline void Dispatched();
39
  // Call this after a request has finished, if re-using this object is planned.
40
  inline void Reset();
41
238702
  T* req() { return &req_; }
42
  inline void Cancel() final;
43
  inline AsyncWrap* GetAsyncWrap() override;
44
45
  static ReqWrap* from_req(T* req);
46
47
  template <typename LibuvFunction, typename... Args>
48
  inline int Dispatch(LibuvFunction fn, Args... args);
49
50
 private:
51
  friend int GenDebugSymbols();
52
  template <typename ReqT, typename U>
53
  friend struct MakeLibuvRequestCallback;
54
55
  typedef void (*callback_t)();
56
  callback_t original_callback_ = nullptr;
57
58
 protected:
59
  // req_wrap_queue_ needs to be at a fixed offset from the start of the class
60
  // because it is used by ContainerOf to calculate the address of the embedding
61
  // ReqWrap. ContainerOf compiles down to simple, fixed pointer arithmetic. It
62
  // is also used by src/node_postmortem_metadata.cc to calculate offsets and
63
  // generate debug symbols for ReqWrap, which assumes that the position of
64
  // members in memory are predictable. sizeof(req_) depends on the type of T,
65
  // so req_wrap_queue_ would no longer be at a fixed offset if it came after
66
  // req_. For more information please refer to
67
  // `doc/guides/node-postmortem-support.md`
68
  T req_;
69
};
70
71
}  // namespace node
72
73
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
74
75
#endif  // SRC_REQ_WRAP_H_