« Back to Product

Documentation

IPS_GetScriptThreads

 array IPS_GetScriptThreads (array $ThreadIDs) 

Parameters

ThreadIDs

Array with the IDs of the threads. If the array is empty, all threads are returned

Returns

An array with one entry per thread in the order of ThreadIDs. If ThreadIDs is empty, the order of the entries is not guaranteed. Each entry has the same structure as in IPS_GetScriptThread.

Description

Warning

This function is intended for internal use only and may change or be removed at any time without notice.

The function returns the information of the threads with the IDs ThreadIDs in one call. If ThreadIDs is empty, all threads are returned. If one of the threads does not exist, the function fails with "ScriptThread #... does not exist".

Warning

The function is intended to be called through the JSON-RPC interface, e.g. for the display in the console. It is not available in PHP scripts ("This function is not available for PHP") – there the result can be determined with IPS_GetScriptThreadList and IPS_GetScriptThread.

PHP scripts are executed in a fixed pool of threads. The number of threads is set by the special switch ThreadCount (default 50, at least 25), and the threads have the IDs 1 to ThreadCount. Within a script, the system variable $_IPS['THREAD'] contains the ID of the own thread.

Example

// Show all threads that are currently busy via the JSON-RPC interface
$rpc = new JSONRPC("http://user:password@127.0.0.1:3777/api/");
foreach ($rpc->IPS_GetScriptThreads([]) as $thread) {
    if ($thread['StartTime'] > 0) {
        printf("Thread %d: %s (%s) for %d s\n", $thread['ThreadID'], $thread['FilePath'], $thread['Sender'], time() - $thread['StartTime']);
    }
}

/* e.g. returns:
Thread 3: scripts/12345.ips.php (RunScript) for 0 s
*/
Any questions?