MCPcopy Create free account
hub / github.com/W4G1/multithreading / constructor

Method constructor

src/lib/json_buffer.ts:128–148  ·  view source on GitHub ↗
(
    obj: T,
    optionsOrBuffer?: SharedArrayBuffer | { size?: number },
  )

Source from the content-addressed store, hash-verified

126 constructor(initial: T, options?: { size?: number });
127 constructor(initial: T, buffer: SharedArrayBuffer);
128 constructor(
129 obj: T,
130 optionsOrBuffer?: SharedArrayBuffer | { size?: number },
131 ) {
132 super();
133 if (optionsOrBuffer instanceof SharedArrayBuffer) {
134 this.buffer = optionsOrBuffer;
135 this.initViews();
136
137 if (Atomics.load(this.u32, OFFSET_FREE_PTR >> 2) === 0) {
138 this.initializeBuffer(obj);
139 }
140 } else {
141 const size = optionsOrBuffer?.size || 1024 * 64;
142 this.buffer = new SharedArrayBuffer(size);
143 this.initViews();
144 this.initializeBuffer(obj);
145 }
146
147 return this.getRootProxy();
148 }
149
150 private initViews() {
151 this.u32 = new Uint32Array(this.buffer);

Callers

nothing calls this directly

Calls 3

initViewsMethod · 0.95
initializeBufferMethod · 0.95
getRootProxyMethod · 0.95

Tested by

no test coverage detected