Changeset 2454 in Sophya for trunk/ArchTOIPipe/Kernel/toisegment.cc
- Timestamp:
- Nov 14, 2003, 1:34:56 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ArchTOIPipe/Kernel/toisegment.cc
r2282 r2454 3 3 // Christophe Magneville 4 4 // Reza Ansari 5 // $Id: toisegment.cc,v 1.2 8 2002-11-28 15:49:21aubourg Exp $5 // $Id: toisegment.cc,v 1.29 2003-11-14 12:34:55 aubourg Exp $ 6 6 7 7 #include "toisegment.h" … … 58 58 59 59 60 double TOISegmented::getData( inti) { /* reader thread */60 double TOISegmented::getData(long i) { /* reader thread */ 61 61 return master->getData(i); 62 62 } 63 63 64 void TOISegmented::getData( inti, double& data, uint_8& flag) { /* reader thread */64 void TOISegmented::getData(long i, double& data, uint_8& flag) { /* reader thread */ 65 65 data = master->getData(i); 66 66 flag = master->getFlag(i); 67 67 } 68 68 69 void TOISegmented::getData( inti, int n, double* data, uint_8* flg) { /* reader thread */69 void TOISegmented::getData(long i, int n, double* data, uint_8* flg) { /* reader thread */ 70 70 master->getData(i, n, data, flg); 71 71 } 72 72 73 void TOISegmented::putData( inti, double value, uint_8 flag) { /* writer thread */73 void TOISegmented::putData(long i, double value, uint_8 flag) { /* writer thread */ 74 74 master->putData(i, value, flag); 75 75 } 76 76 77 void TOISegmented::putData( inti, int n, double const* val, uint_8 const* flg) { /* writer thread */77 void TOISegmented::putData(long i, int n, double const* val, uint_8 const* flg) { /* writer thread */ 78 78 master->putData(i, n, val, flg); 79 79 } … … 83 83 } 84 84 85 void TOISegmented::wontNeedBefore( inti) { /* reader thread */85 void TOISegmented::wontNeedBefore(long i) { /* reader thread */ 86 86 master->getView()->wontNeedBefore(i); 87 87 } 88 88 89 TOI::DataStatus TOISegmented::isDataAvail( int i, intj) {89 TOI::DataStatus TOISegmented::isDataAvail(long i, long j) { 90 90 // return master->getView()->isDataAvail(i, j); 91 91 cout << "TOISegmented::isDataAvail unimplemented" << endl; … … 93 93 } 94 94 95 TOI::DataStatus TOISegmented::isDataAvail( inti) {95 TOI::DataStatus TOISegmented::isDataAvail(long i) { 96 96 return isDataAvail(i,i); 97 97 } 98 98 99 TOI::DataStatus TOISegmented::isDataAvailNL( int i, intj) {99 TOI::DataStatus TOISegmented::isDataAvailNL(long i, long j) { 100 100 return isDataAvail(i,j); 101 101 } 102 102 103 TOI::DataStatus TOISegmented::isDataAvailNL( inti) {103 TOI::DataStatus TOISegmented::isDataAvailNL(long i) { 104 104 return isDataAvail(i); 105 105 } 106 106 107 void TOISegmented::waitForData( int iStart, intiEnd) {107 void TOISegmented::waitForData(long iStart, long iEnd) { 108 108 // get will wait... 109 109 } 110 110 111 void TOISegmented::waitForData( inti) {111 void TOISegmented::waitForData(long i) { 112 112 // get will wait... 113 113 } … … 118 118 } 119 119 120 int TOISegmented::nextDataAvail(intiAfter) {120 long TOISegmented::nextDataAvail(long iAfter) { 121 121 cout << "TOISegmented::nextDataAvail" << endl; 122 122 return iAfter+1; … … 128 128 } 129 129 130 void TOISegmented::doPutData( inti, double value, uint_8 flag) {130 void TOISegmented::doPutData(long i, double value, uint_8 flag) { 131 131 cout << "TOISegmented::doPutData unimplemented" << endl; 132 132 throw PError("TOISegmented::doPutData unimplemented"); 133 133 } 134 134 135 void TOISegmented::doGetData( inti, double& value, uint_8& flag) {135 void TOISegmented::doGetData(long i, double& value, uint_8& flag) { 136 136 cout << "TOISegmented::doGetData unimplemented" << endl; 137 137 throw PError("TOISegmented::doGetData unimplemented"); … … 167 167 } 168 168 169 void TOISegmented::BufferSegment::getData( intsn, int n, double* d, uint_8* f) {169 void TOISegmented::BufferSegment::getData(long sn, int n, double* d, uint_8* f) { 170 170 checkCommitted(); 171 171 checkInRange(sn); … … 177 177 } 178 178 179 void TOISegmented::BufferSegment::putData( intsn, double d, uint_8 f) {179 void TOISegmented::BufferSegment::putData(long sn, double d, uint_8 f) { 180 180 /* writer thread*/ 181 181 if (status == NEW) { … … 192 192 } 193 193 194 void TOISegmented::BufferSegment::putData( intsn, int n, double const* d, uint_8 const* f) {194 void TOISegmented::BufferSegment::putData(long sn, int n, double const* d, uint_8 const* f) { 195 195 if (status == NEW) { 196 196 status = WRITE; … … 252 252 } 253 253 254 double TOISegmented::BufferView::getData( intsn) { /* Single-thread, reader thread*/254 double TOISegmented::BufferView::getData(long sn) { /* Single-thread, reader thread*/ 255 255 ensure(sn); 256 intseg = (sn-sn0)/segmentSize;256 long seg = (sn-sn0)/segmentSize; 257 257 return segments[seg]->getData(sn); 258 258 } 259 259 260 uint_8 TOISegmented::BufferView::getFlag( intsn) { /* Single-thread, reader thread */260 uint_8 TOISegmented::BufferView::getFlag(long sn) { /* Single-thread, reader thread */ 261 261 ensure(sn); 262 intseg = (sn-sn0)/segmentSize;262 long seg = (sn-sn0)/segmentSize; 263 263 return segments[seg]->getFlag(sn); 264 264 } 265 265 266 void TOISegmented::BufferView::getData( intsn, int n, double* dat, uint_8* flg) { /* Single-thread, reader thread */266 void TOISegmented::BufferView::getData(long sn, int n, double* dat, uint_8* flg) { /* Single-thread, reader thread */ 267 267 ensure(sn); 268 268 ensure(sn+n-1); 269 269 270 intsn1 = sn;270 long sn1 = sn; 271 271 int nsam = n; 272 272 double* pdat = dat; … … 274 274 275 275 while (true) { 276 intseg = (sn1-sn0)/segmentSize;276 long seg = (sn1-sn0)/segmentSize; 277 277 BufferSegment* s = segments[seg]; 278 intsnmax = s->sn0 + s->bufferSize - 1;279 intsn2 = snmax > (sn1+nsam-1) ? (sn1+nsam-1) : snmax;280 intnget = sn2-sn1+1;278 long snmax = s->sn0 + s->bufferSize - 1; 279 long sn2 = snmax > (sn1+nsam-1) ? (sn1+nsam-1) : snmax; 280 long nget = sn2-sn1+1; 281 281 s->getData(sn1, nget, pdat, pflg); 282 282 pdat += nget; … … 288 288 } 289 289 290 void TOISegmented::BufferView::ensure( intsn) { /* Single-thread, reader thread */290 void TOISegmented::BufferView::ensure(long sn) { /* Single-thread, reader thread */ 291 291 if (sn < sn0) { 292 292 cout << "TOISegmented::BufferView::ensure : requested sample before first" << endl; … … 321 321 } 322 322 323 void TOISegmented::BufferView::wait( intsn) { /* reader thread, master read wait lock taken */323 void TOISegmented::BufferView::wait(long sn) { /* reader thread, master read wait lock taken */ 324 324 //pthread_mutex_lock(&(master->read_wait_mutex)); 325 325 waiting = true; … … 334 334 335 335 336 void TOISegmented::BufferView::wontNeedBefore( intsn) { /* reader thread */336 void TOISegmented::BufferView::wontNeedBefore(long sn) { /* reader thread */ 337 337 if (sn > firstNeeded) { 338 338 firstNeeded = sn; … … 383 383 } 384 384 385 void TOISegmented::MasterView::putData( intsn, double data, uint_8 flags) { /* writer thread */385 void TOISegmented::MasterView::putData(long sn, double data, uint_8 flags) { /* writer thread */ 386 386 if (sn0<0) { 387 387 LOG(cout << "***MasterView::putData sn0<0 -> " << sn << endl); … … 398 398 } 399 399 400 void TOISegmented::MasterView::putData( intsn, int n, double const* data, uint_8 const* flags) { /* writer thread */400 void TOISegmented::MasterView::putData(long sn, int n, double const* data, uint_8 const* flags) { /* writer thread */ 401 401 if (sn0<0) { 402 402 LOG(cout << "***MasterView::putData sn0<0 -> " << sn << endl); … … 405 405 double const* pdat = data; 406 406 uint_8 const* pflg = flags; 407 intnsam = n;408 intsn1 = sn;407 long nsam = n; 408 long sn1 = sn; 409 409 while (true) { 410 410 // maximum that current segment can take 411 intsnmax = -1;411 long snmax = -1; 412 412 if (currentSegment != NULL) { 413 413 snmax = currentSegment->sn0 + currentSegment->bufferSize-1; 414 414 } 415 intsn2 = snmax > (sn1+nsam-1) ? (sn1+nsam-1) : snmax;416 intnput = sn2-sn1+1;415 long sn2 = snmax > (sn1+nsam-1) ? (sn1+nsam-1) : snmax; 416 long nput = sn2-sn1+1; 417 417 if (snmax>0 && nput>0) { 418 418 currentSegment->putData(sn1, nput, pdat, pflg); … … 428 428 } 429 429 430 double TOISegmented::MasterView::getData( intsn) { /* reader thread */430 double TOISegmented::MasterView::getData(long sn) { /* reader thread */ 431 431 return getView()->getData(sn); /* thread-specific */ 432 432 } 433 433 434 uint_8 TOISegmented::MasterView::getFlag( intsn) { /* reader thread */434 uint_8 TOISegmented::MasterView::getFlag(long sn) { /* reader thread */ 435 435 return getView()->getFlag(sn); 436 436 } 437 437 438 void TOISegmented::MasterView::getData( intsn, int n, double* dat, uint_8* flg) { /* reader thread */438 void TOISegmented::MasterView::getData(long sn, int n, double* dat, uint_8* flg) { /* reader thread */ 439 439 getView()->getData(sn, n, dat, flg); 440 440 } … … 513 513 // int oldBegin = bv->sn0; 514 514 // int oldEnd = bv->sn0 + bv->segmentSize * bv->segments.size(); 515 intoldBegin = sn0;516 intoldEnd = sn0 + bv->segmentSize * segments.size();515 long oldBegin = sn0; 516 long oldEnd = sn0 + bv->segmentSize * segments.size(); 517 517 518 518 for (vector<BufferSegment*>::iterator i = bv->segments.begin(); … … 529 529 530 530 if (nConsumers == allViews.size()) { 531 intfirstNeeded = MAXINT;531 long firstNeeded = MAXINT; 532 532 for (set<BufferView*>::iterator i = allViews.begin(); 533 533 i != allViews.end(); i++) { … … 570 570 571 571 bv->sn0 = -1; 572 intnewEnd = -1;572 long newEnd = -1; 573 573 if (segments.size() > 0) { 574 574 bv->sn0 = bv->segments[0]->sn0;
Note:
See TracChangeset
for help on using the changeset viewer.