Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3135cde authored by Chris Manton's avatar Chris Manton
Browse files

acl_scheduler: Extract policy to send next operation

Bug: 349197968
Test: atest bluetooth_test_gd_unit
Flag: EXEMPT, Mechanical Refactor

Change-Id: I2898f8327be8f594bad467f2e977b0e9a88f08a2
parent 5fd05977
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -14,12 +14,14 @@
 * limitations under the License.
 */

#include "acl_scheduler.h"
#include "hci/acl_manager/acl_scheduler.h"

#include <bluetooth/log.h>

#include <deque>
#include <optional>
#include <unordered_set>
#include <utility>
#include <variant>

namespace bluetooth {
@@ -160,12 +162,17 @@ struct AclScheduler::impl {
  void Stop() { stopped_ = true; }

private:
  bool is_ready_to_send_next_operation() const {
    return incoming_connecting_address_set_.empty() && !outgoing_entry_.has_value() &&
           !pending_outgoing_operations_.empty();
  }

  void try_dequeue_next_operation() {
    if (stopped_) {
      return;
    }
    if (incoming_connecting_address_set_.empty() && !outgoing_entry_.has_value() &&
        !pending_outgoing_operations_.empty()) {

    if (is_ready_to_send_next_operation()) {
      log::info("Pending connections is not empty; so sending next connection");
      auto entry = std::move(pending_outgoing_operations_.front());
      pending_outgoing_operations_.pop_front();