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

Commit 6b501064 authored by Josh Gao's avatar Josh Gao Committed by android-build-merger
Browse files

adb: implement fdevent_reset by constructing a new context. am: 7adca93f

am: 8935c1c8

Change-Id: Ie6123ea0f85e57464ceb4006d420fcd5e56cbdaa
parents a0ea245f 8935c1c8
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -49,10 +49,11 @@ std::string dump_fde(const fdevent* fde) {
                                       state.c_str());
}

static fdevent_context* g_ambient_fdevent_context = new fdevent_context_poll();
static auto& g_ambient_fdevent_context =
        *new std::unique_ptr<fdevent_context>(new fdevent_context_poll());

static fdevent_context* fdevent_get_ambient() {
    return g_ambient_fdevent_context;
    return g_ambient_fdevent_context.get();
}

fdevent* fdevent_create(int fd, fd_func func, void* arg) {
@@ -110,5 +111,5 @@ size_t fdevent_installed_count() {
}

void fdevent_reset() {
    return fdevent_get_ambient()->Reset();
    g_ambient_fdevent_context.reset(new fdevent_context_poll());
}
+0 −1
Original line number Diff line number Diff line
@@ -79,7 +79,6 @@ struct fdevent_context {
    // Test-only functionality:
    virtual void TerminateLoop() = 0;
    virtual size_t InstalledCount() = 0;
    virtual void Reset() = 0;
};

struct fdevent {
+0 −12
Original line number Diff line number Diff line
@@ -458,15 +458,3 @@ void fdevent_context_poll::TerminateLoop() {
size_t fdevent_context_poll::InstalledCount() {
    return poll_node_map_.size();
}

void fdevent_context_poll::Reset() {
    poll_node_map_.clear();
    pending_list_.clear();

    std::lock_guard<std::mutex> lock(run_queue_mutex_);
    run_queue_notify_fd_.reset();
    run_queue_.clear();

    main_thread_valid_ = false;
    terminate_loop_ = false;
}
+0 −1
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ struct fdevent_context_poll : public fdevent_context {

    virtual void TerminateLoop() final;
    virtual size_t InstalledCount() final;
    virtual void Reset() final;

    // All operations to fdevent should happen only in the main thread.
    // That's why we don't need a lock for fdevent.