mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 13:43:49 +01:00
MISC: Switch port.nextWrite() from LIFO to FIFO (#965)
This commit is contained in:
parent
375cf453b3
commit
1ce0584b25
@ -44,7 +44,7 @@ export function writePort(n: PortNumber, value: unknown): PortData | null {
|
|||||||
}
|
}
|
||||||
const { data, resolvers } = getPort(n);
|
const { data, resolvers } = getPort(n);
|
||||||
data.push(value);
|
data.push(value);
|
||||||
while (resolvers.length > 0) resolvers.pop()?.();
|
for (const res of resolvers.splice(0, resolvers.length)) res();
|
||||||
if (data.length > Settings.MaxPortCapacity) return data.shift() as PortData;
|
if (data.length > Settings.MaxPortCapacity) return data.shift() as PortData;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ export function tryWritePort(n: PortNumber, value: unknown): boolean {
|
|||||||
const { data, resolvers } = getPort(n);
|
const { data, resolvers } = getPort(n);
|
||||||
if (data.length >= Settings.MaxPortCapacity) return false;
|
if (data.length >= Settings.MaxPortCapacity) return false;
|
||||||
data.push(value);
|
data.push(value);
|
||||||
while (resolvers.length > 0) resolvers.pop()?.();
|
for (const res of resolvers.splice(0, resolvers.length)) res();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user