Skip to content

Commit

Permalink
Arguments to synchronous (blocking) methods should be passed by const…
Browse files Browse the repository at this point in the history
…-ref instead of by val.
  • Loading branch information
cboulay committed Jun 13, 2022
1 parent ba1acba commit 9e1fc3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/stream_outlet_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ bool stream_outlet_impl::wait_for_consumers(double timeout) {
return send_buffer_->wait_for_consumers(timeout);
}

void stream_outlet_impl::push_timestamp_sync(double timestamp) {
void stream_outlet_impl::push_timestamp_sync(const double& timestamp) {
static_assert(TAG_TRANSMITTED_TIMESTAMP == 2, "Unexpected TAG_TRANSMITTED_TIMESTAMP");
const uint64_t ENDIAN_SAFE_TAG_TRANSMITTED = (2LL << 28) | 2LL;
if (timestamp == DEDUCED_TIMESTAMP) {
Expand All @@ -193,7 +193,7 @@ void stream_outlet_impl::pushthrough_sync() {
}

void stream_outlet_impl::enqueue_sync(
asio::const_buffer buff, double timestamp, bool pushthrough) {
asio::const_buffer buff, const double& timestamp, bool pushthrough) {
push_timestamp_sync(timestamp);
sync_buffs_.push_back(buff);
if (pushthrough) pushthrough_sync();
Expand Down Expand Up @@ -221,7 +221,7 @@ template void stream_outlet_impl::enqueue<double>(const double *data, double, bo
template void stream_outlet_impl::enqueue<std::string>(const std::string *data, double, bool);

void stream_outlet_impl::enqueue_sync_multi(
std::vector<asio::const_buffer> buffs, double timestamp, bool pushthrough) {
std::vector<asio::const_buffer> buffs, const double& timestamp, bool pushthrough) {
push_timestamp_sync(timestamp);
sync_buffs_.insert(sync_buffs_.end(), buffs.begin(), buffs.end());
if (pushthrough) pushthrough_sync();
Expand Down
6 changes: 3 additions & 3 deletions src/stream_outlet_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,22 +310,22 @@ class stream_outlet_impl {

/// Append the appropriate timestamp tag and optionally timestamp onto sync_buffs_ for a single
/// timestamp.
void push_timestamp_sync(double timestamp);
void push_timestamp_sync(const double& timestamp);

/// push sync_buffs_ through each tcp server.
void pushthrough_sync();

/// Append a single timestamp and single buffer to sync_buffs and optionally pushthrough the
/// server.
void enqueue_sync(asio::const_buffer buff, double timestamp, bool pushthrough);
void enqueue_sync(asio::const_buffer buff, const double& timestamp, bool pushthrough);

/**
* Append a single timestamp and multiple within-sample buffers to sync_buffs_.
* This is useful when a sample is discontiguous in memory. It makes no assumptions about how
* many channels are included in each buffer.
*/
void enqueue_sync_multi(
std::vector<asio::const_buffer> buffs, double timestamp, bool pushthrough);
std::vector<asio::const_buffer> buffs, const double& timestamp, bool pushthrough);

/**
* Check whether some given number of channels matches the stream's channel_count.
Expand Down

0 comments on commit 9e1fc3c

Please sign in to comment.