@@ -24,7 +24,6 @@ using uprotocol::v1::UStatus;
2424using ListenHandle = uprotocol::transport::UTransport::ListenHandle;
2525
2626struct PendingRequest {
27- private:
2827 std::chrono::steady_clock::time_point when_expire;
2928 ListenHandle response_listener;
3029 std::function<void (UStatus)> expire;
@@ -69,7 +68,7 @@ struct RpcClient::ExpireService {
6968
7069 void enqueue (std::chrono::steady_clock::time_point when_expire,
7170 transport::UTransport::ListenHandle&& response_listener,
72- std::function<void (v1::UStatus)> expire) {
71+ std::function<void (v1::UStatus)> expire) const {
7372 detail::PendingRequest pending;
7473 pending.when_expire = when_expire;
7574 pending.response_listener = std::move (response_listener);
@@ -247,17 +246,19 @@ RpcClient::InvokeFuture::InvokeFuture(std::future<MessageOrStatus>&& future,
247246namespace {
248247namespace detail {
249248
250- using namespace uprotocol ;
251- using namespace std ::chrono_literals;
249+ using uprotocol::v1::UStatus;
250+ using uprotocol::v1::UCode;
251+ // using namespace std::chrono_literals;
252+ using ListenHandle = uprotocol::transport::UTransport::ListenHandle;
252253
253254auto PendingRequest::operator >(const PendingRequest& other) const {
254255 return when_expire > other.when_expire ;
255256}
256257
257258ScrubablePendingQueue::~ScrubablePendingQueue () {
258- const v1:: UStatus cancel_reason = []() {
259- v1:: UStatus reason;
260- reason.set_code (v1:: UCode::INTERNAL);
259+ const UStatus cancel_reason = []() {
260+ UStatus reason;
261+ reason.set_code (UCode::INTERNAL);
261262 reason.set_message (
262263 " ERROR: ExpireWorker has shut down while requests are still "
263264 " pending. This should never occur and likely indicates that an "
@@ -273,7 +274,7 @@ ScrubablePendingQueue::~ScrubablePendingQueue() {
273274auto ScrubablePendingQueue::scrub (size_t instance_id) {
274275 // Collect all the expire lambdas so they can be called without the
275276 // lock held.
276- std::vector<std::function<void (v1:: UStatus)>> all_expired;
277+ std::vector<std::function<void (UStatus)>> all_expired;
277278
278279 c.erase (
279280 std::remove_if (c.begin (), c.end (),
@@ -286,7 +287,7 @@ auto ScrubablePendingQueue::scrub(size_t instance_id) {
286287 }),
287288 c.end ());
288289
289- // TODO - is there a better way to shrink the internal container?
290+ // TODO(missing_author) - is there a better way to shrink the internal container?
290291 // Maybe instead we should enforce a capacity limit
291292 constexpr size_t CAPACITY_SHRINK_THRESHOLD = 16 ;
292293 if ((c.capacity () > CAPACITY_SHRINK_THRESHOLD) &&
@@ -307,29 +308,29 @@ ExpireWorker::ExpireWorker() {
307308ExpireWorker::~ExpireWorker () {
308309 stop_ = true ;
309310 {
310- std::lock_guard lock (pending_mtx_);
311+ std::lock_guard const lock (pending_mtx_);
311312 wake_worker_.notify_one ();
312313 }
313314 worker_.join ();
314315}
315316
316317void ExpireWorker::enqueue (PendingRequest&& pending) {
317- std::lock_guard lock (pending_mtx_);
318+ std::lock_guard const lock (pending_mtx_);
318319 pending_.emplace (std::move (pending));
319320 wake_worker_.notify_one ();
320321}
321322
322323void ExpireWorker::scrub (size_t instance_id) {
323- std::vector<std::function<void (v1:: UStatus)>> all_expired;
324+ std::vector<std::function<void (UStatus)>> all_expired;
324325 {
325- std::lock_guard lock (pending_mtx_);
326+ std::lock_guard const lock (pending_mtx_);
326327 all_expired = pending_.scrub (instance_id);
327328 wake_worker_.notify_one ();
328329 }
329330
330- static const v1:: UStatus cancel_reason = []() {
331- v1:: UStatus reason;
332- reason.set_code (v1:: UCode::CANCELLED);
331+ static const UStatus cancel_reason = []() {
332+ UStatus reason;
333+ reason.set_code (UCode::CANCELLED);
333334 reason.set_message (" RpcClient for this request was discarded" );
334335 return reason;
335336 }();
@@ -345,8 +346,8 @@ void ExpireWorker::doWork() {
345346 std::optional<decltype (PendingRequest::expire)> maybe_expire;
346347
347348 {
348- transport::UTransport:: ListenHandle expired_handle;
349- std::lock_guard lock (pending_mtx_);
349+ ListenHandle expired_handle;
350+ std::lock_guard const lock (pending_mtx_);
350351 if (!pending_.empty ()) {
351352 const auto when_expire = pending_.top ().when_expire ;
352353 if (when_expire <= now) {
@@ -361,9 +362,9 @@ void ExpireWorker::doWork() {
361362 if (maybe_expire) {
362363 auto & expire = *maybe_expire;
363364
364- static const v1:: UStatus expire_reason = []() {
365- v1:: UStatus reason;
366- reason.set_code (v1:: UCode::DEADLINE_EXCEEDED);
365+ static const UStatus expire_reason = []() {
366+ UStatus reason;
367+ reason.set_code (UCode::DEADLINE_EXCEEDED);
367368 reason.set_message (" Request expired before response received" );
368369 return reason;
369370 }();
0 commit comments