@@ -1503,7 +1503,7 @@ fn do_wait_critical<'gc, const IS_ASYNC: bool, const IS_I64: bool>(
15031503 let ( new_guard, timeout) = waiter_record. wait_timeout ( guard, dur) ;
15041504 guard = new_guard;
15051505 if timeout. timed_out ( ) {
1506- guard. remove_from_list ( byte_index_in_buffer, waiter_record) ;
1506+ guard. remove_from_list ( byte_index_in_buffer, & waiter_record) ;
15071507
15081508 // 31. Perform LeaveCriticalSection(WL).
15091509 // 32. If mode is sync, return waiterRecord.[[Result]].
@@ -1645,16 +1645,15 @@ impl WaitAsyncJob {
16451645 self . 0 . _has_timeout
16461646 }
16471647
1648- /// Implementation of the Job Abstract Closure for [WaitAsyncTimeoutJob](https://tc39.es/ecma262/#sec-enqueueatomicswaitasynctimeoutjob),
1648+ /// Implementation of the Job Abstract Closure for
1649+ /// [WaitAsyncTimeoutJob](https://tc39.es/ecma262/#sec-enqueueatomicswaitasynctimeoutjob),
16491650 /// for the cases where no timeout is specified.
1650- pub ( crate ) fn run < ' gc > ( self , agent : & mut Agent , gc : GcScope < ' gc , ' _ > ) -> JsResult < ' gc , ( ) > {
1651- let gc = gc. into_nogc ( ) ;
1652-
1651+ pub ( crate ) fn run < ' gc > ( self , agent : & mut Agent , gc : NoGcScope < ' gc , ' _ > ) -> JsResult < ' gc , ( ) > {
16531652 let waiters = get_wait_async_job_waiters ( & self . 0 . data_block ) ;
16541653
16551654 let mut guard = waiters. lock ( ) . unwrap ( ) ;
16561655 let waiter_record = self . 0 . waiter_record ;
1657- guard. remove_from_list ( self . 0 . byte_index_in_buffer , waiter_record. clone ( ) ) ;
1656+ guard. remove_from_list ( self . 0 . byte_index_in_buffer , & waiter_record) ;
16581657
16591658 let result = match waiter_record. get_result ( ) {
16601659 Some ( WaitResult :: TimedOut ) => WaitResult :: TimedOut ,
@@ -1683,24 +1682,28 @@ struct WaitAsyncTimeoutJobInner {
16831682pub ( crate ) struct WaitAsyncTimeoutJob ( Box < WaitAsyncTimeoutJobInner > ) ;
16841683
16851684impl WaitAsyncTimeoutJob {
1686- pub ( crate ) fn run < ' gc > ( self , _agent : & mut Agent , _gc : GcScope < ' gc , ' _ > ) -> JsResult < ' gc , ( ) > {
1687- if self . 0 . waiter_record . get_result ( ) . is_some ( ) {
1688- return Ok ( ( ) ) ;
1685+ pub ( crate ) fn run < ' gc > ( self ) {
1686+ let WaitAsyncTimeoutJobInner {
1687+ data_block,
1688+ byte_index_in_buffer,
1689+ waiter_record,
1690+ } = * self . 0 ;
1691+ if waiter_record. get_result ( ) . is_some ( ) {
1692+ return ;
16891693 }
16901694
1691- let waiters = get_wait_async_job_waiters ( & self . 0 . data_block ) ;
1695+ let waiters = get_wait_async_job_waiters ( & data_block) ;
16921696 // a. Perform EnterCriticalSection(WL).
16931697 let mut guard = waiters. lock ( ) . unwrap ( ) ;
16941698
16951699 // b. If WL.[[Waiters]] contains waiterRecord, then
16961700 // i. Let timeOfJobExecution be the time value (UTC) identifying the current time.
16971701 // ii. Assert: ℝ(timeOfJobExecution) ≥ waiterRecord.[[TimeoutTime]] (ignoring potential non-monotonicity of time values).
16981702 // iii. Set waiterRecord.[[Result]] to "timed-out".
1699- self . 0 . waiter_record . set_result ( WaitResult :: TimedOut ) ;
1703+ waiter_record. set_result ( WaitResult :: TimedOut ) ;
17001704
17011705 // iv. Perform RemoveWaiter(WL, waiterRecord).
1702- let waiter_record = self . 0 . waiter_record . clone ( ) ;
1703- guard. remove_from_list ( self . 0 . byte_index_in_buffer , self . 0 . waiter_record ) ;
1706+ guard. remove_from_list ( byte_index_in_buffer, & waiter_record) ;
17041707
17051708 // v. Perform NotifyWaiter(WL, waiterRecord).
17061709 waiter_record. notify_waiters ( ) ;
@@ -1709,7 +1712,6 @@ impl WaitAsyncTimeoutJob {
17091712 drop ( guard) ;
17101713
17111714 // d. Return unused.
1712- Ok ( ( ) )
17131715 }
17141716}
17151717
0 commit comments