Adding comments about threading around CreatePeerConnectionFactory.
This has confused a lot of developers (understandably). R=pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/1828463002 . Cr-Commit-Position: refs/heads/master@{#12105}
This commit is contained in:
parent
f752f85f3d
commit
a8415fe9ea
@ -64,16 +64,11 @@ CreatePeerConnectionFactory() {
|
||||
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
|
||||
new rtc::RefCountedObject<PeerConnectionFactory>());
|
||||
|
||||
|
||||
// Call Initialize synchronously but make sure its executed on
|
||||
// |signaling_thread|.
|
||||
MethodCall0<PeerConnectionFactory, bool> call(
|
||||
pc_factory.get(),
|
||||
&PeerConnectionFactory::Initialize);
|
||||
bool result = call.Marshal(pc_factory->signaling_thread());
|
||||
|
||||
if (!result) {
|
||||
return NULL;
|
||||
RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread());
|
||||
// The signaling thread is the current thread so we can
|
||||
// safely call Initialize directly.
|
||||
if (!pc_factory->Initialize()) {
|
||||
return nullptr;
|
||||
}
|
||||
return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(),
|
||||
pc_factory);
|
||||
@ -101,7 +96,7 @@ CreatePeerConnectionFactory(
|
||||
bool result = call.Marshal(signaling_thread);
|
||||
|
||||
if (!result) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory);
|
||||
}
|
||||
|
||||
@ -634,12 +634,25 @@ class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
|
||||
};
|
||||
|
||||
// Create a new instance of PeerConnectionFactoryInterface.
|
||||
//
|
||||
// This method relies on the thread it's called on as the "signaling thread"
|
||||
// for the PeerConnectionFactory it creates.
|
||||
//
|
||||
// As such, if the current thread is not already running an rtc::Thread message
|
||||
// loop, an application using this method must eventually either call
|
||||
// rtc::Thread::Current()->Run(), or call
|
||||
// rtc::Thread::Current()->ProcessMessages() within the application's own
|
||||
// message loop.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory();
|
||||
|
||||
// Create a new instance of PeerConnectionFactoryInterface.
|
||||
// Ownership of |factory|, |default_adm|, and optionally |encoder_factory| and
|
||||
// |decoder_factory| transferred to the returned factory.
|
||||
//
|
||||
// |worker_thread| and |signaling_thread| are the only mandatory
|
||||
// parameters.
|
||||
//
|
||||
// If non-null, ownership of |default_adm|, |encoder_factory| and
|
||||
// |decoder_factory| are transferred to the returned factory.
|
||||
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
||||
CreatePeerConnectionFactory(
|
||||
rtc::Thread* worker_thread,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user