/*
 * MIT License
 * Author: Mark Allyn
 *
 * target_buffer.cpp
 */

#include "target_buffer.h"

void TargetBuffer::write(const std::array<TargetState, MAX_TARGETS>& src, int count) {
    std::lock_guard<std::mutex> lk(mutex_);
    data_  = src;
    count_ = count;
    ++gen_;
}

int TargetBuffer::read(std::array<TargetState, MAX_TARGETS>& dst) const {
    std::lock_guard<std::mutex> lk(mutex_);
    dst = data_;
    return count_;
}

uint64_t TargetBuffer::generation() const {
    std::lock_guard<std::mutex> lk(mutex_);
    return gen_;
}
