mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Remove the async_hooks-based AsyncLocalStorage fallback and the --no-async-context-frame flag, making AsyncContextFrame the sole implementation. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/63641 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
43 lines
764 B
JavaScript
43 lines
764 B
JavaScript
'use strict';
|
|
|
|
const {
|
|
SafeMap,
|
|
} = primordials;
|
|
|
|
const {
|
|
getContinuationPreservedEmbedderData,
|
|
setContinuationPreservedEmbedderData,
|
|
} = internalBinding('async_context_frame');
|
|
|
|
class AsyncContextFrame extends SafeMap {
|
|
constructor(store, data) {
|
|
super(AsyncContextFrame.current());
|
|
this.set(store, data);
|
|
}
|
|
|
|
static current() {
|
|
return getContinuationPreservedEmbedderData();
|
|
}
|
|
|
|
static set(frame) {
|
|
setContinuationPreservedEmbedderData(frame);
|
|
}
|
|
|
|
static exchange(frame) {
|
|
const prior = this.current();
|
|
this.set(frame);
|
|
return prior;
|
|
}
|
|
|
|
static disable(store) {
|
|
const frame = this.current();
|
|
frame?.disable(store);
|
|
}
|
|
|
|
disable(store) {
|
|
this.delete(store);
|
|
}
|
|
}
|
|
|
|
module.exports = AsyncContextFrame;
|