File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -443,6 +443,12 @@ const threadObserver = Process.attachThreadObserver({
443443} ) ;
444444threadObserver . detach ( ) ;
445445
446+ // $ExpectType Promise<void>
447+ Process . runOnThread ( 1 , ( ) => { } ) ;
448+
449+ // $ExpectType Promise<boolean>
450+ Process . runOnThread ( 1 , ( ) => true ) ;
451+
446452const moduleObserver = Process . attachModuleObserver ( {
447453 onAdded ( module ) {
448454 // $ExpectType Module
Original file line number Diff line number Diff line change @@ -380,6 +380,20 @@ declare namespace Process {
380380 */
381381 function attachThreadObserver ( callbacks : ThreadObserverCallbacks ) : ThreadObserver ;
382382
383+ /**
384+ * Runs the JavaScript function `callback` on the thread specified by `id`.
385+ * Must be used with extreme caution due to the thread potentially being
386+ * interrupted in non-reentrant code. For example, you could be interrupting
387+ * it while it's in the middle of some delicate code, holding a specific
388+ * non-recursive lock, which you then try to implicitly acquire again when
389+ * you call some function.
390+ *
391+ * @param id ID of the thread to run on.
392+ * @param callback Function to run.
393+ * @returns A Promise that resolves to the value returned by `callback`.
394+ */
395+ function runOnThread < T > ( id : ThreadId , callback : ( ) => T ) : Promise < T > ;
396+
383397 /**
384398 * Looks up a module by address. Returns null if not found.
385399 */
You can’t perform that action at this time.
0 commit comments