MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / makeMutClosure

Function makeMutClosure

ppom/src/ppom.js:187–210  ·  view source on GitHub ↗
(arg0, arg1, dtor, f)

Source from the content-addressed store, hash-verified

185}
186
187function makeMutClosure(arg0, arg1, dtor, f) {
188 const state = { a: arg0, b: arg1, cnt: 1 };
189 const real = (...args) => {
190 // First up with a closure we increment the internal reference
191 // count. This ensures that the Rust closure environment won't
192 // be deallocated while we're invoking it.
193 state.cnt++;
194 const a = state.a;
195 state.a = 0;
196 try {
197 return f(a, state.b, ...args);
198 } finally {
199 if (--state.cnt === 0) {
200 dtor(a, state.b);
201
202 } else {
203 state.a = a;
204 }
205 }
206 };
207 real.original = state;
208
209 return real;
210}
211function __wbg_adapter_20(arg0, arg1, arg2) {
212 wasm.wasm_bindgen__convert__closures__invoke1_mut(arg0, arg1, addHeapObject(arg2));
213}

Callers 1

__wbg_get_importsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected