Changeset 12765 for tests


Ignore:
Timestamp:
Mar 14, 2014, 8:26:33 PM (10 years ago)
Author:
hock@…
Message:

new functionality: SystemQueue::leave() and SystemQueue::join()

( + unit tests)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/SystemQueue-tests.cc

    r12764 r12765  
    102102       
    103103        checkmark = true;
     104    }
     105
     106    void Leave()
     107    {
     108        // let's do something before leaving..
     109        this->LongRunner();
     110        checkmark = false;
     111       
     112        cout << "### Leaving SysQ ### "<< endl;
     113        SystemQueue::instance().leave();
    104114    }
    105115
     
    223233
    224234/**
     235 *  leaves the SystemQueue from inside a scheduled event (in contrast to cancel)
     236 *
     237 *  NOTE: due to the SystemQueue singleton design, explicit cleanup is necessary!
     238 *
     239 *  [ NOTE: the old System Queue does not support this. ]
     240 */
     241TEST_F(SystemQueueTest, LeaveFromInsideEvent)
     242{
     243    SystemQueue& sysq = SystemQueue::instance();
     244   
     245    // start
     246    sysq.run();
     247   
     248    // scheduleCall
     249    sysq.scheduleCall(
     250        boost::bind(&SystemQueueTest::Leave, this)
     251    );
     252
     253    // schedule another which must NOT be performed
     254    sysq.scheduleCall(
     255        boost::bind(&SystemQueueTest::Check, this)
     256    );
     257   
     258    // sleep until the SystemQueue thread has finished
     259    sysq.join();
     260   
     261    EXPECT_FALSE( sysq.isRunning() );
     262   
     263    // ensure Check() was not perfomed
     264    EXPECT_FALSE( sysq.isEmpty() );
     265    EXPECT_FALSE( checkmark );
     266   
     267    // CLEANUP
     268    sysq.cancel();
     269   
     270    EXPECT_FALSE( sysq.isRunning() );
     271    EXPECT_TRUE( sysq.isEmpty() );
     272}
     273
     274
     275/**
    225276 *  schedule a call and test whether it is actually performed by the SystemQueue
    226277 */
Note: See TracChangeset for help on using the changeset viewer.