[ntcore] StructArrayTopic: Publish schema in span-taking setters (#6303)

This commit is contained in:
Peter Johnson
2024-01-23 21:26:06 -08:00
committed by GitHub
parent 9d55941ce5
commit 3acae550d6

View File

@@ -312,6 +312,9 @@ class StructArrayPublisher : public Publisher {
void Set(std::span<const T> value, int64_t time = 0) {
std::apply(
[&](const I&... info) {
if (!m_schemaPublished.exchange(true, std::memory_order_relaxed)) {
GetTopic().GetInstance().template AddStructSchema<T>(info...);
}
m_buf.Write(
value,
[&](auto bytes) { ::nt::SetRaw(m_pubHandle, bytes, time); },
@@ -356,6 +359,9 @@ class StructArrayPublisher : public Publisher {
void SetDefault(std::span<const T> value) {
std::apply(
[&](const I&... info) {
if (!m_schemaPublished.exchange(true, std::memory_order_relaxed)) {
GetTopic().GetInstance().template AddStructSchema<T>(info...);
}
m_buf.Write(
value,
[&](auto bytes) { ::nt::SetDefaultRaw(m_pubHandle, bytes); },