@@ -1544,11 +1544,11 @@ export default class GMApi extends GM_Base {
15441544 return this . loadScriptPromise ;
15451545 }
15461546
1547- @GMContext . API ( { alias : "GM_runExclusive " } )
1548- [ "GM.runExclusive " ] < T > ( lockKey : string , cb : ( ) => T | PromiseLike < T > , timeout : number = - 1 ) : Promise < T > {
1547+ @GMContext . API ( { alias : "GM_takeTurn " } )
1548+ [ "GM.takeTurn " ] < T > ( lockKey : string , cb : ( ) => T | PromiseLike < T > , timeout : number = - 1 ) : Promise < T > {
15491549 lockKey = `${ lockKey } ` ; // 转化为字串
15501550 if ( ! lockKey || ! this . scriptRes ) {
1551- throw new Error ( "GM.runExclusive : Invalid Calling" ) ;
1551+ throw new Error ( "GM.takeTurn : Invalid Calling" ) ;
15521552 }
15531553 const key = `${ getStorageName ( this . scriptRes ) . replace ( / : / g, ":_" ) } ::${ lockKey . replace ( / : / g, ":_" ) } ` ;
15541554
@@ -1563,7 +1563,7 @@ export default class GMApi extends GM_Base {
15631563 if ( error ) {
15641564 reject ( error ) ;
15651565 } else if ( state !== 2 ) {
1566- reject ( new Error ( "GM.runExclusive : Incomplete Action" ) ) ;
1566+ reject ( new Error ( "GM.takeTurn : Incomplete Action" ) ) ;
15671567 } else {
15681568 resolve ( result ) ;
15691569 }
@@ -1590,7 +1590,7 @@ export default class GMApi extends GM_Base {
15901590 con . disconnect ( ) ;
15911591 onDisconnected ( ) ; // in case .disconnect() not working
15921592 } ;
1593- this . connect ( "runExclusive " , [ key ] ) . then ( ( con ) => {
1593+ this . connect ( "takeTurn " , [ key ] ) . then ( ( con ) => {
15941594 if ( killConn === null || state > 0 ) {
15951595 // already resolved (unexpected or by timeout)
15961596 con . disconnect ( ) ;
@@ -1611,15 +1611,15 @@ export default class GMApi extends GM_Base {
16111611 if ( timeout > 0 ) {
16121612 setTimeout ( ( ) => {
16131613 if ( killConn === null || state > 0 ) return ; // 执行开始了就不进行 timeout 操作
1614- error = new Error ( "GM.runExclusive : Timeout Error" ) ;
1614+ error = new Error ( "GM.takeTurn : Timeout Error" ) ;
16151615 killConn ?.( ) ;
16161616 onDisconnected ( ) ; // in case .disconnect() not working
16171617 } , timeout ) ;
16181618 }
16191619 } ) ;
16201620
16211621 return new Promise ( ( resolve , reject ) => {
1622- stackAsyncTask ( `runExclusive ::${ key } ` , async ( ) => {
1622+ stackAsyncTask ( `takeTurn ::${ key } ` , async ( ) => {
16231623 try {
16241624 resolve ( await taskAsync ( ) ) ;
16251625 } catch ( e ) {
0 commit comments