Line data Source code
1 : #include "Tools/Reporter/Probe/Reporter_probe.hpp" 2 : 3 : namespace spu 4 : { 5 : namespace tools 6 : { 7 : 8 : template<typename T> 9 : size_t 10 4264 : Reporter_probe::col_size(const int col) 11 : { 12 4264 : return this->head[col] - this->tail[col] + (this->head[col] >= this->tail[col] ? 0 : this->buffer[col].size()); 13 : } 14 : 15 : template<typename T> 16 : bool 17 2028 : Reporter_probe::push(const int col, const T* elts) 18 : { 19 2028 : std::unique_lock<std::mutex> lck(this->mtx[col]); 20 2028 : if (this->col_size<T>(col) == this->buffer[col].size() - 1) return false; 21 2028 : auto buff = reinterpret_cast<T*>(this->buffer[col][this->head[col]].data()); 22 2028 : std::copy(elts, elts + this->data_sizes[col], buff); 23 2028 : this->head[col] = (this->head[col] + 1) % this->buffer[col].size(); 24 2028 : return true; 25 2028 : } 26 : 27 : template<typename T> 28 : bool 29 2236 : Reporter_probe::pull(const int col, T* elts) 30 : { 31 2236 : std::unique_lock<std::mutex> lck(this->mtx[col]); 32 2236 : if (this->col_size<T>(col) == 0) return false; 33 2028 : auto buff = reinterpret_cast<const T*>(this->buffer[col][this->tail[col]].data()); 34 2028 : std::copy(buff, buff + this->data_sizes[col], elts); 35 2028 : this->tail[col] = (this->tail[col] + 1) % this->buffer[col].size(); 36 2028 : return true; 37 2236 : } 38 : 39 : } 40 : }