MCPcopy Index your code
hub / github.com/nodejs/node / buildDestroy

Function buildDestroy

benchmark/async_hooks/async-resource-vs-destroy.js:66–99  ·  view source on GitHub ↗
(getServe)

Source from the content-addressed store, hash-verified

64}
65
66function buildDestroy(getServe) {
67 const transactions = new Map();
68 const server = createServer(getServe(getCLS, setCLS));
69 const hook = createHook({ init, destroy });
70 hook.enable();
71
72 return {
73 server,
74 close,
75 };
76
77 function getCLS() {
78 const asyncId = executionAsyncId();
79 return transactions.has(asyncId) ? transactions.get(asyncId) : null;
80 }
81
82 function setCLS(value) {
83 const asyncId = executionAsyncId();
84 transactions.set(asyncId, value);
85 }
86
87 function init(asyncId, type, triggerAsyncId, resource) {
88 transactions.set(asyncId, getCLS());
89 }
90
91 function destroy(asyncId) {
92 transactions.delete(asyncId);
93 }
94
95 function close() {
96 hook.disable();
97 server.close();
98 }
99}
100
101function buildAsyncLocalStorage(getServe) {
102 const asyncLocalStorage = new AsyncLocalStorage();

Callers

nothing calls this directly

Calls 3

createServerFunction · 0.50
createHookFunction · 0.50
enableMethod · 0.45

Tested by

no test coverage detected