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

Commit 117698b8 authored by Alex Sakhartchouk's avatar Alex Sakhartchouk
Browse files

Add LambdaMessage to SurfaceFlinger

LambdaMessage allows for a cleaner, more compact way to create and
dispatch messages inside SurfaceFlinger. A follow up CL uses this
method, but it was isolated here to keep added functionality and
helper facilities separate.

Bug: 62215749
Test: Compile
Change-Id: I9e13e04f1b67fd60f01bcab02fe4f19c91c10bd4
parent 3cfa9a9b
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,8 @@


#include "Barrier.h"
#include "Barrier.h"


#include <functional>

namespace android {
namespace android {


class IDisplayEventConnection;
class IDisplayEventConnection;
@@ -58,6 +60,21 @@ private:
    mutable Barrier barrier;
    mutable Barrier barrier;
};
};


class LambdaMessage : public MessageBase {
public:
    explicit LambdaMessage(std::function<void()> handler)
          : MessageBase(), mHandler(std::move(handler)) {}

    bool handler() override {
        mHandler();
        // This return value is no longer checked, so it's always safe to return true
        return true;
    }

private:
    const std::function<void()> mHandler;
};

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


class MessageQueue {
class MessageQueue {