зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1843568 - Part 3: Annotate `nsIEventTarget` as rust_sync, r=xpcom-reviewers,barret
All event targets should be threadsafe and implemented in C++, and so should be able to be used in `Sync` types in Rust code. This also required annotating all interfaces deriving from `nsIEventTarget`, as well as adding some associated constants to specific types to indicate to the static assertion that they have threadsafe reference counts. Differential Revision: https://phabricator.services.mozilla.com/D183592
This commit is contained in:
Родитель
5c7b57345b
Коммит
effc2ca999
|
@ -10,6 +10,7 @@
|
|||
#define mozilla_RefCounted_h
|
||||
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
|
@ -256,6 +257,9 @@ class RefCounted {
|
|||
}
|
||||
}
|
||||
|
||||
using HasThreadSafeRefCnt =
|
||||
std::integral_constant<bool, Atomicity == AtomicRefCount>;
|
||||
|
||||
// Compatibility with wtf::RefPtr.
|
||||
void ref() { AddRef(); }
|
||||
void deref() { Release(); }
|
||||
|
|
|
@ -181,6 +181,8 @@ class SupportsThreadSafeWeakPtr : public detail::SupportsThreadSafeWeakPtrBase {
|
|||
return cnt;
|
||||
}
|
||||
|
||||
using HasThreadSafeRefCnt = std::true_type;
|
||||
|
||||
// Compatibility with wtf::RefPtr
|
||||
void ref() { AddRef(); }
|
||||
void deref() { Release(); }
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define SharedThreadPool_h_
|
||||
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include "mozilla/AlreadyAddRefed.h"
|
||||
#include "mozilla/RefCountType.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -52,6 +53,7 @@ class SharedThreadPool : public nsIThreadPool {
|
|||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
||||
NS_IMETHOD_(MozExternalRefCountType) AddRef(void) override;
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release(void) override;
|
||||
using HasThreadSafeRefCnt = std::true_type;
|
||||
|
||||
// Forward behaviour to wrapped thread pool implementation.
|
||||
NS_FORWARD_SAFE_NSITHREADPOOL(mPool);
|
||||
|
|
|
@ -17,7 +17,7 @@ class nsITargetShutdownTask;
|
|||
native alreadyAddRefed_nsIRunnable(already_AddRefed<nsIRunnable>);
|
||||
[ptr] native nsITargetShutdownTask(nsITargetShutdownTask);
|
||||
|
||||
[builtinclass, scriptable, uuid(a03b8b63-af8b-4164-b0e5-c41e8b2b7cfa)]
|
||||
[builtinclass, scriptable, rust_sync, uuid(a03b8b63-af8b-4164-b0e5-c41e8b2b7cfa)]
|
||||
interface nsIEventTarget : nsISupports
|
||||
{
|
||||
/* until we can get rid of all uses, keep the non-alreadyAddRefed<> version */
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* - However, one can "convert" a thread pool into an nsISerialEventTarget
|
||||
* by putting a TaskQueue in front of it.
|
||||
*/
|
||||
[builtinclass, scriptable, uuid(9f982380-24b4-49f3-88f6-45e2952036c7)]
|
||||
[builtinclass, scriptable, rust_sync, uuid(9f982380-24b4-49f3-88f6-45e2952036c7)]
|
||||
interface nsISerialEventTarget : nsIEventTarget
|
||||
{
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ native TimeDuration(mozilla::TimeDuration);
|
|||
*
|
||||
* See nsIThreadManager for the API used to create and locate threads.
|
||||
*/
|
||||
[builtinclass, scriptable, uuid(5801d193-29d1-4964-a6b7-70eb697ddf2b)]
|
||||
[builtinclass, scriptable, rust_sync, uuid(5801d193-29d1-4964-a6b7-70eb697ddf2b)]
|
||||
interface nsIThread : nsISerialEventTarget
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@ interface nsIThreadObserver;
|
|||
* The XPCOM thread object implements this interface, which allows a consumer
|
||||
* to observe dispatch activity on the thread.
|
||||
*/
|
||||
[builtinclass, scriptable, uuid(a3a72e5f-71d9-4add-8f30-59a78fb6d5eb)]
|
||||
[builtinclass, scriptable, rust_sync, uuid(a3a72e5f-71d9-4add-8f30-59a78fb6d5eb)]
|
||||
interface nsIThreadInternal : nsIThread
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ interface nsIThreadPoolListener : nsISupports
|
|||
* anonymous (unnamed) worker threads. An event dispatched to the thread pool
|
||||
* will be run on the next available worker thread.
|
||||
*/
|
||||
[uuid(76ce99c9-8e43-489a-9789-f27cc4424965)]
|
||||
[rust_sync, uuid(76ce99c9-8e43-489a-9789-f27cc4424965)]
|
||||
interface nsIThreadPool : nsIEventTarget
|
||||
{
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче