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
@@ -67,6 +67,12 @@ public:
sender_.allowAnonymousTransfers();
}
/**
* Priority of outgoing transfers.
*/
TransferPriority getPriority() const { return sender_.getPriority(); }
void setPriority(const TransferPriority prio) { sender_.setPriority(prio); }
INode& getNode() const { return node_; }
};
+2 -18
View File
@@ -65,24 +65,6 @@ public:
return BaseType::publish(message, TransferTypeMessageBroadcast, NodeID::Broadcast, tid);
}
/**
* Returns priority of outgoing transfers.
*/
TransferPriority getPriority() const
{
return BaseType::getTransferSender().getPriority();
}
/**
* Allows to change the priority of outgoing transfers.
* Note that only High, Normal and Low priorities can be used; Service priority is not available for messages.
* If the priority value is invalid, an assertion failure will be generated, and the value will not be updated.
*/
void setPriority(const TransferPriority prio)
{
BaseType::getTransferSender().setPriority(prio);
}
static MonotonicDuration getDefaultTxTimeout() { return MonotonicDuration::fromMSec(10); }
/**
@@ -97,6 +79,8 @@ public:
using BaseType::getMaxTxTimeout;
using BaseType::getTxTimeout;
using BaseType::setTxTimeout;
using BaseType::getPriority;
using BaseType::setPriority;
using BaseType::getNode;
};
@@ -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); }
};
// ----------------------------------------------------------------------------