Changeset 1993 in Sophya for trunk/ArchTOIPipe/Kernel


Ignore:
Timestamp:
May 9, 2002, 10:22:37 PM (23 years ago)
Author:
ansari
Message:

Ajout de lock()/unlock() ds toiseqbuff.cc - Reza 9/5/2002

Location:
trunk/ArchTOIPipe/Kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/Kernel/toi.h

    r1766 r1993  
    55//                               Christophe Magneville
    66//                               Reza Ansari
    7 // $Id: toi.h,v 1.15 2001-11-14 14:49:05 aubourg Exp $
     7// $Id: toi.h,v 1.16 2002-05-09 20:22:37 ansari Exp $
    88
    99#ifndef TOI_H
     
    127127
    128128  //   ----- Rajouts Reza 12/3/2001
    129   void wait() {pthread_cond_wait(&condv, &mutex);}
    130   void signal() {pthread_cond_signal(&condv);}
    131   void broadcast() {pthread_cond_broadcast(&condv);}
     129  inline void wait() {pthread_cond_wait(&condv, &mutex);}
     130  inline void signal() {pthread_cond_signal(&condv);}
     131  inline void broadcast() {pthread_cond_broadcast(&condv);}
    132132  inline void waitPut()
    133133    {fgwaitput=true; countwaitput++; pthread_cond_wait(&condv, &mutex);}
     
    136136  inline bool isPutWaiting() const { return fgwaitput; }
    137137  inline bool isGetWaiting() const { return fgwaitget; }
    138   inline void signalPut() {fgsigput=true;}
    139   inline void signalGet() {fgsigget=true;}
     138  inline void signalPut() {fgsigput=true; }
     139  inline void signalGet() {fgsigget=true; }
    140140  inline void cleanWaitPut() { fgsigput = fgwaitput = false; }
    141141  inline void cleanWaitGet() { fgsigget = fgwaitget = false; }
  • trunk/ArchTOIPipe/Kernel/toiseqbuff.cc

    r1992 r1993  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: toiseqbuff.cc,v 1.12 2002-05-08 22:22:33 ansari Exp $
     5// $Id: toiseqbuff.cc,v 1.13 2002-05-09 20:22:37 ansari Exp $
    66
    77#include "toiprocessor.h"
     
    125125
    126126void TOISeqBuffered::getData(int i, double & val, uint_8 & flg) {
     127  lock();
    127128  if (!started) {
    128129    cout << " TOISeqBuffered::getData() - waitGet() Waiting for start ... " << endl;
     
    135136           << " i=" << i << " next_in= " << next_in
    136137           << " next_out=" << next_out << endl;
     138    unlock();
    137139    throw RangeCheckError("TOISeqBuffered::getData(i) : data deleted");
    138140  }
     
    158160           << " i=" << i << " next_in= " << next_in
    159161           << " next_out=" << next_out << endl;
    160     signalPut(); broadcast();
    161   }
     162    signalPut();
     163  }
     164  unlock();
     165  if (fgsigput)  signal();
    162166  return;
    163167}
     
    166170void TOISeqBuffered::getData(int i, int n, double* data, uint_8* flg)
    167171{
     172  lock();
    168173  if (!started) {
    169174    cout << " TOISeqBuffered::getData(i,n ...) - waitGet() Waiting for start ... " << endl;
     
    176181           << " i=" << i << " next_in= " << next_in
    177182           << " next_out=" << next_out << endl;
     183    unlock();
    178184    throw RangeCheckError("TOISeqBuffered::getData(i) : data deleted");
    179185  }
     
    200206             << " i=" << i << " next_in= " << next_in
    201207             << " next_out=" << next_out << endl;
    202       signalPut(); broadcast();
    203     }
    204   }
    205   return;
    206  
     208      signalPut();
     209    }
     210  }
     211  unlock();
     212  if (fgsigput)  signal();
     213  return; 
    207214}
    208215
     
    238245
    239246void TOISeqBuffered::putData(int i, double value, uint_8 flag) {
     247  lock();
    240248  if (!started) {
    241249    first_in = next_in = i;
     
    250258             << " next_out=" << next_out << endl;
    251259      string msg = "TOISeqBuffered::putData() : i!=next_in TOIname="  + getName();
     260      unlock();
    252261      throw RangeCheckError(msg);
    253262    }
     
    272281           << " i=" << i << " next_in= " << next_in
    273282           << " next_out=" << next_out << endl;
    274     signalGet(); broadcast();
    275   }
    276 }
    277 
    278 void TOISeqBuffered::putData(int i, int n, double const* val, uint_8 const* flg) {
     283    signalGet();
     284  }
     285  unlock();
     286  if (fgsigget)  signal();
     287  return;
     288}
     289
     290void TOISeqBuffered::putData(int i, int n, double const* val, uint_8 const* flg)
     291{
     292  lock();
    279293  if (!started) {
    280294    first_in = next_in = i;
     
    289303             << " next_out=" << next_out << endl;
    290304      string msg = "TOISeqBuffered::putData() : i!=next_in TOIname="  + getName();
     305      unlock();
    291306      throw RangeCheckError(msg);
    292307    }
     
    314329           << " i=" << i << " next_in= " << next_in
    315330           << " next_out=" << next_out << endl;
    316     signalGet(); broadcast();
    317   }
     331    signalGet();
     332  }
     333  unlock();
     334  if (fgsigget)  signal();
     335  return;
    318336}
    319337
Note: See TracChangeset for help on using the changeset viewer.