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

Commit fc741c72 authored by Myles Watson's avatar Myles Watson
Browse files

Remove is_main_thread

This was only used to ensure that a test function
wasn't called from the main thread.  Mark the function
as test-only.

Bug: 289277431
Test: atest pts-bot
Change-Id: I0028f0a8bcc03381e3fac97d89ce59f0ba140138
parent a8b3cb11
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -156,7 +156,6 @@ bt_status_t do_in_jni_thread(base::OnceClosure task);
bt_status_t do_in_jni_thread(const base::Location& from_here,
                             base::OnceClosure task);
bool is_on_jni_thread();
btbase::AbstractMessageLoop* get_jni_message_loop();

using BtJniClosure = std::function<void()>;
void post_on_bt_jni(BtJniClosure closure);
+0 −4
Original line number Diff line number Diff line
@@ -177,10 +177,6 @@ bool is_on_jni_thread() {
  return jni_thread.GetThreadId() == PlatformThread::CurrentId();
}

btbase::AbstractMessageLoop* get_jni_message_loop() {
  return jni_thread.message_loop();
}

static void do_post_on_bt_jni(BtJniClosure closure) { closure(); }

void post_on_bt_jni(BtJniClosure closure) {
+2 −9
Original line number Diff line number Diff line
@@ -33,10 +33,6 @@ namespace common {
static constexpr int kRealTimeFifoSchedulingPriority = 1;

MessageLoopThread::MessageLoopThread(const std::string& thread_name)
    : MessageLoopThread(thread_name, false) {}

MessageLoopThread::MessageLoopThread(const std::string& thread_name,
                                     bool is_main)
    : thread_name_(thread_name),
      message_loop_(nullptr),
      run_loop_(nullptr),
@@ -44,8 +40,7 @@ MessageLoopThread::MessageLoopThread(const std::string& thread_name,
      thread_id_(-1),
      linux_tid_(-1),
      weak_ptr_factory_(this),
      shutting_down_(false),
      is_main_(is_main) {}
      shutting_down_(false) {}

MessageLoopThread::~MessageLoopThread() { ShutDown(); }

@@ -143,10 +138,8 @@ void MessageLoopThread::RunThread(MessageLoopThread* thread,
  thread->Run(std::move(start_up_promise));
}

// This is only for use in tests.
btbase::AbstractMessageLoop* MessageLoopThread::message_loop() const {
  ASSERT_LOG(!is_main_,
             "you are not allowed to get the main thread's message loop");

  std::lock_guard<std::recursive_mutex> api_lock(api_mutex_);
  return message_loop_;
}
+0 −2
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ class MessageLoopThread final {
   * @param thread_name name of this worker thread
   */
  explicit MessageLoopThread(const std::string& thread_name);
  explicit MessageLoopThread(const std::string& thread_name, bool is_main);

  MessageLoopThread(const MessageLoopThread&) = delete;
  MessageLoopThread& operator=(const MessageLoopThread&) = delete;
@@ -199,7 +198,6 @@ class MessageLoopThread final {
  pid_t linux_tid_;
  base::WeakPtrFactory<MessageLoopThread> weak_ptr_factory_;
  bool shutting_down_;
  bool is_main_;
};

inline std::ostream& operator<<(std::ostream& os,
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ using bluetooth::hci::IsoManager;
/* Define BTU storage area */
uint8_t btu_trace_level = HCI_INITIAL_TRACE_LEVEL;

static MessageLoopThread main_thread("bt_main_thread", true);
static MessageLoopThread main_thread("bt_main_thread");

void btu_hci_msg_process(BT_HDR* p_msg) {
  /* Determine the input message type. */
Loading