SF: Modernize task scheduling API
Replace postMessageAsync and postMessageSync with schedule(<lambda>)
returning std::future<T>, where T is the return type of the lambda,
for an ergonomic and less error-prone API.
Rewrite the hand-rolled synchronization logic in captureScreenCommon.
Bug: 123715322
Bug: 134772048
Test: go/wm-smoke
Test: screencap
Test: libsurfaceflinger_unittest
Change-Id: I02dc4114b61fb175463941ab5890e3127dd57a11
diff --git a/services/surfaceflinger/MonitoredProducer.cpp b/services/surfaceflinger/MonitoredProducer.cpp
index 5009e10..18a2891 100644
--- a/services/surfaceflinger/MonitoredProducer.cpp
+++ b/services/surfaceflinger/MonitoredProducer.cpp
@@ -38,13 +38,7 @@
// because we don't know where this destructor is called from. It could be
// called with the mStateLock held, leading to a dead-lock (it actually
// happens).
- sp<LambdaMessage> cleanUpListMessage =
- new LambdaMessage([flinger = mFlinger, asBinder = wp<IBinder>(onAsBinder())]() {
- Mutex::Autolock lock(flinger->mStateLock);
- flinger->mGraphicBufferProducerList.erase(asBinder);
- });
-
- mFlinger->postMessageAsync(cleanUpListMessage);
+ mFlinger->removeGraphicBufferProducerAsync(onAsBinder());
}
status_t MonitoredProducer::requestBuffer(int slot, sp<GraphicBuffer>* buf) {