Changeset 8583

Show
Ignore:
Timestamp:
01/17/09 03:43:39 (4 years ago)
Author:
caguayog
Message:

Moving processing thread creation to start method. Mutex added for synchronization but may be unnecessary

Location:
ossiedev/trunk/components/TxDemo
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/trunk/components/TxDemo/TxDemo.cpp

    r8362 r8583  
    3333    // initialize packet delay to be 5 seconds 
    3434    packet_delay = 5000; 
    35  
    36     //Create the thread for the writer's processing function  
    37     processing_thread = new omni_thread(Run, (void *) this); 
    38  
    39     //Start the thread containing the writer's processing function  
    40     processing_thread->start(); 
    41  
    4235} 
    4336 
     
    7366{ 
    7467    DEBUG(3, TxDemo, "start() invoked") 
    75     thread_started=true; 
     68    thread_started = true;    //initialize 
     69    //Create the thread for the writer's processing function  
     70    processing_thread = new omni_thread(Run, (void *) this); 
     71 
     72    //Start the thread containing the writer's processing function  
     73    processing_thread->start(); 
    7674} 
    7775 
     
    7977 
    8078    DEBUG(3, TxDemo, "stop() invoked") 
     79    processing_mutex.lock(); 
    8180    thread_started=false; 
     81    processing_mutex.unlock(); 
    8282} 
    8383 
     
    131131    } 
    132132 
    133     while(true) { 
    134         if (thread_started) { 
    135             // push data to output 
    136             dataOutPort->pushPacket(I_out, Q_out); 
    137  
    138             // wait 
    139             usleep(packet_delay*1000); 
    140         } 
     133    while(continue_processing()) { 
     134        // push data to output 
     135        dataOutPort->pushPacket(I_out, Q_out); 
     136 
     137        // wait 
     138        usleep(packet_delay*1000); 
    141139    } 
    142140} 
    143  
     141bool TxDemo_i::continue_processing(void) 
     142{ 
     143    bool status; 
     144    processing_mutex.lock(); 
     145    status = thread_started; 
     146    processing_mutex.unlock(); 
     147    return status; 
     148} 
    144149 
    145150unsigned char data_i[512] = { 
  • ossiedev/trunk/components/TxDemo/TxDemo.h

    r8362 r8583  
    8585    /// Main signal processing method 
    8686    void ProcessData(); 
    87     bool thread_started; 
     87    bool continue_processing(void);     ///< for start - stop processing 
     88    volatile bool thread_started; 
     89    omni_mutex processing_mutex; 
    8890    
    8991    omni_condition *component_running;  ///< for component shutdown