MISC: Make spawn able to have 0 delay (#1333)

This eliminates a hole where spawn was unrelaible, because other scripts
could jump in and steal the RAM. It's not an API break, because 0 used
to be an invalid value.
This commit is contained in:
David Walker
2024-06-28 18:41:41 -07:00
committed by GitHub
parent 06d742a7f3
commit 1c20a24079
6 changed files with 39 additions and 13 deletions

View File

@@ -283,7 +283,10 @@ interface RunOptions {
/** @public */
interface SpawnOptions extends RunOptions {
/** Number of milliseconds to delay before spawning script, defaults to 10000 (10s). Must be a positive integer. */
/**
* Number of milliseconds to delay before spawning script, defaults to 10000 (10s).
* Must be a non-negative integer. If 0, the script will be spawned synchronously.
*/
spawnDelay?: number;
}
@@ -6261,6 +6264,9 @@ export interface NS {
* constrained by the RAM usage of the current one. This function can only be used to run scripts
* on the local server.
*
* The delay specified can be 0; in this case the new script will synchronously replace
* the old one. (There will not be any opportunity for other scripts to use up the RAM in-between.)
*
* Because this function immediately terminates the script, it does not have a return value.
*
* Running this function with 0 or fewer threads will cause a runtime error.