// Ref-counted guard for safe cross-thread portal access from GDBus callbacks. // Callbacks lock the mutex and check the portal pointer before use. // Stop() nulls the pointer under the same mutex, waiting for any in-flight // callback to finish. struct PortalGuard : public RefCountedNonVirtual<PortalGuard> {
Mutex mutex;
gpointer portal = nullptr;
// RAII lock for PortalGuard. Use ScopedPortalLock for async callbacks // (releases the callback's ref) or ScopedPortalSignalLock for signal // callbacks (ref is owned by the subscription).
enum class RefOwnership {
kOwnedByCallback, // Async: callback owns the ref, release on unlock.
kOwnedBySubscription, // Signal: subscription owns the ref via // GDestroyNotify.
};
// For async callbacks. Releases the ref on destruction because async // callbacks fire exactly once and own their ref. class ScopedPortalLock : public ScopedPortalLockBase { public:
explicit ScopedPortalLock(gpointer user_data)
: ScopedPortalLockBase(user_data, RefOwnership::kOwnedByCallback) {}
};
// For signal callbacks. Does not release the ref because the signal // subscription owns it. The ref is released by portal_guard_release // (GDestroyNotify) when the subscription is removed. class ScopedPortalSignalLock : public ScopedPortalLockBase { public:
explicit ScopedPortalSignalLock(gpointer user_data)
: ScopedPortalLockBase(user_data, RefOwnership::kOwnedBySubscription) {}
};
} // namespace webrtc
#endif// MODULES_PORTAL_PORTAL_GUARD_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-08-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.