Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
BufferSource.ccGo to the documentation of this file.00001 #if 0 00002 #include "BufferSource.h" 00003 #include "Shared/MarkScope.h" 00004 #include <pthread.h> 00005 00006 //better to put this here instead of the header 00007 using namespace std; 00008 00009 unsigned int BufferSource::getData(const char *& payload, unsigned int& payloadSize, unsigned int& t, std::string& n) { 00010 if(thread==NULL) 00011 return frame; 00012 MarkScope l(swapLock); 00013 while(!isReady) { 00014 readySignal.wait(swapLock); 00015 swapLock.lock(); 00016 if(thread==NULL) { // in case we shut down while waiting 00017 payload=NULL; 00018 payloadSize=0; 00019 return frame; 00020 } 00021 } 00022 payload=&readyBuffer.front(); 00023 payloadSize=readyBuffer.size(); 00024 t=readyTimestamp; 00025 n=readyName; 00026 isReady=false; 00027 return frame; 00028 } 00029 00030 void BufferSource::signalReady() { 00031 MarkScope l(swapLock); 00032 swap(timestamp,readyTimestamp); 00033 swap(name,readyName); 00034 buffer.swap(readyBuffer); // could use std::swap() and rely on STL providing specialization, but let's be explicit 00035 ++frame; 00036 readySignal.broadcast(); 00037 } 00038 00039 00040 /*! @file 00041 * @brief 00042 * @author Ethan Tira-Thompson (ejt) (Creator) 00043 */ 00044 #endif |
Tekkotsu Hardware Abstraction Layer 5.1CVS |
Generated Mon May 9 05:01:37 2016 by Doxygen 1.6.3 |