/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Rust Bindgen code doesn't actually use these types, but `UniqueFileHandle` // and `UniqueMachSendRight` aren't defined and some headers need to type check, // so we define a dummy pointer type. #ifdefined(RUST_BINDGEN) using PlatformHandle = void*; #elifdefined(XP_DARWIN) using PlatformHandle = mozilla::UniqueMachSendRight; #else using PlatformHandle = mozilla::UniqueFileHandle; #endif
struct Handle; struct ReadOnlyHandle;
class HandleBase { public: /** * The size of the shared memory region to which this handle refers.
*/
uint64_t Size() const { return mSize; }
/** * Whether this shared memory handle is valid.
*/ bool IsValid() const { return (bool)*this; }
/** * Whether this shared memory handle is valid.
*/ explicitoperatorbool() const { return (bool)mHandle; }
/** * Map the shared memory region into memory.
*/ struct ReadOnlyMapping Map(void* aFixedAddress = nullptr) const;
};
/** * A freezable handle to a shared memory region. * * One cannot clone this handle, ensuring that at most one writable mapping * exists. After freezing, no new writable mappings can be created.
*/ struct FreezableHandle : HandleBase { /** * Create an empty FreezableHandle.
*/
FreezableHandle() = default;
MOZ_IMPLICIT FreezableHandle(std::nullptr_t) {}
~FreezableHandle();
/** * Create a new shared memory region.
*/
Handle Create(uint64_t aSize);
/** * Create a new freezable shared memory region. * * Freezable shared memory regions are distinguished by the property that there * is guaranteed to be at most one writable mapping of the region at a time. * * Furthermore, a freezable shared memory region can be frozen while mapped. In * this case, the mapping remains valid but there can be no new writable * mappings.
*/
FreezableHandle CreateFreezable(uint64_t aSize);
} // namespace shared_memory
using MutableSharedMemoryHandle = shared_memory::Handle; using ReadOnlySharedMemoryHandle = shared_memory::ReadOnlyHandle; using FreezableSharedMemoryHandle = shared_memory::FreezableHandle;
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 ist noch experimentell.