| 688 | } |
| 689 | |
| 690 | Slot Connection::callMethodAsync(sd_bus_message* sdbusMsg, sd_bus_message_handler_t callback, void* userData, uint64_t timeout, return_slot_t) |
| 691 | { |
| 692 | sd_bus_slot *slot{}; |
| 693 | |
| 694 | // TODO: Think of ways of optimizing these three locking/unlocking of sdbus mutex (merge into one call?) |
| 695 | auto timeoutBefore = getEventLoopPollData().timeout; |
| 696 | auto r = sdbus_->sd_bus_call_async(nullptr, &slot, sdbusMsg, callback, userData, timeout); |
| 697 | SDBUS_THROW_ERROR_IF(r < 0, "Failed to call method asynchronously", -r); |
| 698 | auto timeoutAfter = getEventLoopPollData().timeout; |
| 699 | |
| 700 | // An event loop may wait in poll with timeout `t1', while in another thread an async call is made with |
| 701 | // timeout `t2'. If `t2' < `t1', then we have to wake up the event loop thread to update its poll timeout. |
| 702 | // We also have to wake up the event loop to process the messages that may be in the read/write queues. |
| 703 | if (timeoutAfter < timeoutBefore || arePendingMessagesInQueues()) |
| 704 | notifyEventLoopToWakeUpFromPoll(); |
| 705 | |
| 706 | return {slot, [this](void *slot){ sdbus_->sd_bus_slot_unref(static_cast<sd_bus_slot*>(slot)); }}; |
| 707 | } |
| 708 | |
| 709 | void Connection::sendMessage(sd_bus_message* sdbusMsg) |
| 710 | { |
nothing calls this directly
no test coverage detected