Changeset 4828


Ignore:
Timestamp:
Jul 9, 2009, 11:08:45 AM (15 years ago)
Author:
Christoph Mayer
Message:

timer reset function

Location:
source/ariba/utility/system
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/utility/system/Timer.cpp

    r3690 r4828  
    8484}
    8585
     86void Timer::reset(){
     87#ifndef UNDERLAY_OMNET
     88        if(timerThread == NULL) return;
     89        timerThread->interrupt();
     90#else
     91        #error timer interruption not implemented for omnet
     92#endif
     93}
     94
    8695void Timer::stop() {
    8796        running = false;
     97        reset(); // cause the sleep to abort
    8898}
    8999
     
    97107
    98108        while( obj->running ) {
    99                 boost::this_thread::sleep( boost::posix_time::milliseconds(obj->millis) );
     109
     110                try{
     111                        boost::this_thread::sleep( boost::posix_time::milliseconds(obj->millis) );
     112                }catch(boost::thread_interrupted e){
     113                        // exception called when Timer::reset is called
     114                        // don't need to handle the exception
     115                }
     116
    100117                if (obj->running) SystemQueue::instance().scheduleEvent( SystemEvent( obj, TimerEventType, NULL), 0 );
    101118                if( obj->oneshot ) break;
  • source/ariba/utility/system/Timer.h

    r3690 r4828  
    6565        ~Timer();
    6666
     67        /**
     68         * Set the interval for the timer
     69         *
     70         * @param millis Timer interval in milliseconds
     71         * @param oneshot Is this a one-shot or periodic timer
     72         */
    6773        void setInterval(unsigned int millis, bool oneshot=false);
     74
     75        /**
     76         * Start the timer
     77         */
    6878        void start();
     79
     80        /**
     81         * Stop the timer
     82         */
    6983        void stop();
     84
     85        /**
     86         * Reset a running timer and ignore the remaining interval
     87         * time. Start the timer with a new timer interval.
     88         */
     89        void reset();
    7090
    7191protected:
Note: See TracChangeset for help on using the changeset viewer.