src/connectivity/wlan/drivers/third_party/broadcom/brcmfmac/test/workqueue_test.cc
// Upon canceling a job that has not started yet, it should never run, and the cancel should
// return without blocking.
Upon canceling a job that has not started yet, it should never run, and the cancel should
return without blocking.
Upon canceling a job that has not started yet it should never run and the cancel should return without blocking .
TEST(Workqueue, CancelPending) {
  WorkQueue* queue = new WorkQueue("MyWork");
  TestWork work1;
  TestWork work2;
  TestWork work3;
  work1.work = WorkItem(handler);
  work2.work = WorkItem(handler);
  work3.work = WorkItem(handler);
  queue->Schedule(&work1.work);
  queue->Schedule(&work2.work);
  queue->Schedule(&work3.work);
  sync_completion_wait(&work1.entered, ZX_TIME_INFINITE);
  EXPECT_EQ(work1.state, 1);
  EXPECT_EQ(work2.state, 0);
  work2.work.Cancel();
  sync_completion_signal(&work1.proceed);
  sync_completion_wait(&work3.entered, ZX_TIME_INFINITE);
  EXPECT_EQ(work1.state, 2);
  EXPECT_EQ(work2.state, 0);
  EXPECT_EQ(work3.state, 1);
  sync_completion_signal(&work3.proceed);
  delete queue;
}
TEST ( Workqueue , CancelPending ) { WorkQueue * queue = new WorkQueue ( " " ) ; TestWork work1 ; TestWork work2 ; TestWork work3 ; work1 . work = WorkItem ( handler ) ; work2 . work = WorkItem ( handler ) ; work3 . work = WorkItem ( handler ) ; queue -> Schedule ( & work1 . work ) ; queue -> Schedule ( & work2 . work ) ; queue -> Schedule ( & work3 . work ) ; sync_completion_wait ( & work1 . entered , ZX_TIME_INFINITE ) ; EXPECT_EQ ( work1 . state , 1 ) ; EXPECT_EQ ( work2 . state , 0 ) ; work2 . work . Cancel ( ) ; sync_completion_signal ( & work1 . proceed ) ; sync_completion_wait ( & work3 . entered , ZX_TIME_INFINITE ) ; EXPECT_EQ ( work1 . state , 2 ) ; EXPECT_EQ ( work2 . state , 0 ) ; EXPECT_EQ ( work3 . state , 1 ) ; sync_completion_signal ( & work3 . proceed ) ; delete queue ; }
Upon canceling a job that has not started yet, it should never run, and the cancel should
return without blocking.
Upon canceling a job that has not started yet it should never run and the cancel should return without blocking .