Relanding: Use std::unique_ptr instead of rtc::scoped_refptr in AsyncInvoker.

The AsyncClosures only ever have one thing referencing them, so they
should be using std::unique_ptr to manage ownership. Maybe this code was
written before std::unique_ptr was available.

Originally reverted because it made a change to ScopedMessageData
that wasn't backwards compatible, and applications using the rtc::Thread
infrastructure may be using it.

BUG=None
NOTRY=True

Review-Url: https://codereview.webrtc.org/2689233003
Cr-Commit-Position: refs/heads/master@{#16684}
This commit is contained in:
deadbeef
2017-02-17 18:06:26 -08:00
committed by Commit bot
parent 884a7284bd
commit a8bc1a1f63
4 changed files with 41 additions and 34 deletions

View File

@ -15,8 +15,6 @@
#include "webrtc/base/callback.h"
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/messagehandler.h"
#include "webrtc/base/refcount.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/thread.h"
@ -25,15 +23,13 @@ namespace rtc {
class AsyncInvoker;
// Helper class for AsyncInvoker. Runs a task and triggers a callback
// on the calling thread if necessary. Instances are ref-counted so their
// lifetime can be independent of AsyncInvoker.
class AsyncClosure : public RefCountInterface {
// on the calling thread if necessary.
class AsyncClosure {
public:
virtual ~AsyncClosure() {}
// Runs the asynchronous task, and triggers a callback to the calling
// thread if needed. Should be called from the target thread.
virtual void Execute() = 0;
protected:
~AsyncClosure() override {}
};
// Simple closure that doesn't trigger a callback for the calling thread.