Changeset 2386 in Sophya for trunk/ArchTOIPipe/Kernel/ringpipe.cc


Ignore:
Timestamp:
May 20, 2003, 12:10:09 PM (22 years ago)
Author:
aubourg
Message:

ring pipes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/Kernel/ringpipe.cc

    r2385 r2386  
    33//                               Christophe Magneville
    44//                               Reza Ansari
    5 // $Id: ringpipe.cc,v 1.1 2003-05-19 23:31:29 aubourg Exp $
     5// $Id: ringpipe.cc,v 1.2 2003-05-20 10:10:08 aubourg Exp $
    66
    77#include "ringpipe.h"
     
    1515#endif
    1616
    17 RingPipe::RingPipe() {
     17RingPipe::RingPipe(int ws) {
    1818  i0 = -1;
     19  winSize = ws;
    1920  producer = NULL;
    2021  pthread_cond_init(&ringReady, NULL);
     
    3839void RingPipe::putRing(int i, Ring const* ring) {
    3940  lock();
     41  waitForRoom(i);
    4042  if (i0 == -1) {
    4143    data.insert(data.begin(), 1, (Ring const*) NULL);
     
    5052  notify();
    5153  unlock();
     54}
     55
     56void RingPipe::waitForRoom(int j) {
     57  while (j-i0 >= winSize) {
     58    wait();
     59  }
    5260}
    5361
     
    9199    data.erase(data.begin(), data.begin()+(i-i0));
    92100    i0=i;
     101    notify();
    93102  }
    94103  unlock();
Note: See TracChangeset for help on using the changeset viewer.