Skip to content

Message batching#

AES70 traffic often consists of many small messages. To use the network efficiently it is therefore important to make sure that many small commands or events are combined into larger messages.

In libaes70 this happens on two levels:

  • If possible libae70 will try to combine identical AES70 message types into larger AES70 messages.
  • If possible libaes70 will try to buffer data for sending in order to write larger chunks as once.

Since it is in general difficult to decide when to buffer and wait for additional messages to be generated, this only happens under in the following situations:

  1. While processing incoming data outgoing messages are not immediately sent. This makes sure that - usually - a series of commands which are received from a controller are respnded to in the same response message. A similar logic is applied for controllers.

  2. When connections are manually set to buffer data using the cork() and uncork() methods.

One typical example for when to use the cork() and uncork() API is when sending out level meter updates on multiple channels or other property changes.

An example for this can be found in examples/devices/gains_and_levels/device.cpp:

static void update_level_meters(uv_timer_t *)
{
  auto tmp = device.cork_handle();

  for (auto &level : levels)
    level.get().update_level(random_level());
}

The cork_handle() in the above examples returns an object which calls cork() on construction and uncork() on destruction. This provides an exception-safe mechanism to cork and uncork connections.

Warn

Make sure to not cork() devices or connections for a long period. It is usually not safe to do that. Specifically it must not be possible for new connections to be created while a device is cork()ed. It is usually ok to cork() temporarily in a function.