Configurable priority for service calls; plus a minor collateral refactoring

This commit is contained in:
Pavel Kirienko
2015-07-03 09:56:52 +03:00
parent 546fda2b39
commit f015c2de8b
6 changed files with 75 additions and 18 deletions
@@ -208,6 +208,9 @@ public:
* reference invalidates once the callback returns. If you want to use this object after the callback execution,
* you need to copy it somewhere.
*
* Note that by default, service client objects use lower priority than message publishers. Use @ref setPriority()
* to override the default if necessary.
*
* @tparam DataType_ Service data type.
*
* @tparam Callback_ Service response will be delivered through the callback of this type.
@@ -303,6 +306,7 @@ public:
, publisher_(node, getDefaultRequestTimeout())
, callback_(callback)
{
setPriority(TransferPriority::MiddleLower);
setRequestTimeout(getDefaultRequestTimeout());
#if UAVCAN_DEBUG
UAVCAN_ASSERT(getRequestTimeout() == getDefaultRequestTimeout()); // Making sure default values are OK
@@ -398,6 +402,14 @@ public:
publisher_.setTxTimeout(timeout);
request_timeout_ = max(timeout, publisher_.getTxTimeout()); // No less than TX timeout
}
/**
* Priority of outgoing request transfers.
* The remote server is supposed to use the same priority for the response, but it's not guaranteed by
* the specification.
*/
TransferPriority getPriority() const { return publisher_.getPriority(); }
void setPriority(const TransferPriority prio) { publisher_.setPriority(prio); }
};
// ----------------------------------------------------------------------------