| 224 | } |
| 225 | |
| 226 | template<typename T> void |
| 227 | GenericDataSaver::write(const T *data, size_t size) |
| 228 | { |
| 229 | if (this->writer->canWrite()) { |
| 230 | QMutexLocker locker(&this->dataMutex); |
| 231 | size_t totalBytes = this->buffers[this->buffer].size(); |
| 232 | size_t avail = (totalBytes - this->ptr) / sizeof(T); |
| 233 | |
| 234 | this->dataWritten = true; |
| 235 | |
| 236 | if (size > avail) { |
| 237 | emit swamped(); |
| 238 | return; |
| 239 | } |
| 240 | |
| 241 | // Copy data |
| 242 | memcpy( |
| 243 | this->buffers[this->buffer].data() + this->ptr, |
| 244 | data, |
| 245 | size * sizeof(T)); |
| 246 | |
| 247 | this->ptr += size * sizeof(T); |
| 248 | |
| 249 | if (this->ptr > totalBytes / 2) { |
| 250 | // Buffer starts to get filled up, issue commit request |
| 251 | this->doCommit(); |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | // Explicit instantiation of these ones |
| 257 | template void GenericDataSaver::write<SUCOMPLEX>(const SUCOMPLEX *, size_t); |