| qsharedmemory.cpp |
!
\class QSharedMemory
\inmodule QtCore
\since 4.4
\brief The QSharedMemory class provides access to a shared memory segment.
QSharedMemory provides access to a \l{Shared Memory}{shared memory segment}
by multiple threads and processes. Shared memory segments are identified by a
key, represented by \l QNativeIpcKey. A key can be created in a
cross-platform manner by using platformSafeKey().
One QSharedMemory object must create() the segment and this call specifies
the size of the segment. All other processes simply attach() to the segment
that must already exist. After either operation is successful, the
application may call data() to obtain a pointer to the data.
To support non-atomic operations, QSharedMemory provides API to gain
exclusive access: you may lock the shared memory with lock() before reading
from or writing to the shared memory, but remember to release the lock with
unlock() after you are done.
By default, QSharedMemory automatically destroys the shared memory segment
when the last instance of QSharedMemory is \l{detach()}{detached} from the
segment, and no references to the segment remain.
For details on the key types, platform-specific limitations, and
interoperability with older or non-Qt applications, see the \l{Native IPC
Keys} documentation. That includes important information for sandboxed
applications on Apple platforms, including all apps obtained via the Apple
App Store.
\sa {Inter-Process Communication}, QSystemSemaphore
|
21569 |
- |
| qsharedmemory.h |
|
2501 |
- |
| qsharedmemory_p.h |
!
Helper class
|
6084 |
- |
| qsharedmemory_posix.cpp |
|
5732 |
- |
| qsharedmemory_systemv.cpp |
!
\internal
If not already made create the handle used for accessing the shared memory.
|
5750 |
- |
| qsharedmemory_win.cpp |
|
4873 |
- |
| qsystemsemaphore.cpp |
!
\class QSystemSemaphore
\inmodule QtCore
\since 4.4
\brief The QSystemSemaphore class provides a general counting system semaphore.
A system semaphore is a generalization of \l QSemaphore. Typically, a
semaphore is used to protect a certain number of identical resources.
Like its lighter counterpart, a QSystemSemaphore can be
accessed from multiple \l {QThread} {threads}. Unlike QSemaphore, a
QSystemSemaphore can also be accessed from multiple \l {QProcess}
{processes}. This means QSystemSemaphore is a much heavier class, so
if your application doesn't need to access your semaphores across
multiple processes, you will probably want to use QSemaphore.
Semaphores support two fundamental operations, acquire() and release():
acquire() tries to acquire one resource. If there isn't a resource
available, the call blocks until a resource becomes available. Then
the resource is acquired and the call returns.
release() releases one resource so it can be acquired by another
process. The function can also be called with a parameter n > 1,
which releases n resources.
System semaphores are identified by a key, represented by \l QNativeIpcKey. A
key can be created in a cross-platform manner by using platformSafeKey(). A
system semaphore is created by the QSystemSemaphore constructor when passed
an access mode parameter of AccessMode::Create. Once it is created, other
processes may attach to the same semaphore using the same key and an access
mode parameter of AccessMode::Open.
Example: Create a system semaphore
\snippet code/src_corelib_kernel_qsystemsemaphore.cpp 0
For details on the key types, platform-specific limitations, and
interoperability with older or non-Qt applications, see the \l{Native IPC
Keys} documentation. That includes important information for sandboxed
applications on Apple platforms, including all apps obtained via the Apple
App Store.
\sa {Inter-Process Communication}, QSharedMemory, QSemaphore
|
14271 |
- |
| qsystemsemaphore.h |
|
2212 |
- |
| qsystemsemaphore_p.h |
|
4289 |
- |
| qsystemsemaphore_posix.cpp |
|
5748 |
- |
| qsystemsemaphore_systemv.cpp |
!
\internal
Setup unix_key
|
5809 |
- |
| qsystemsemaphore_win.cpp |
|
3153 |
- |
| qtipccommon.cpp |
!
\internal
Legacy: this exists for compatibility with QSharedMemory and
QSystemSemaphore between 4.4 and 6.6.
Returns a QNativeIpcKey that contains a platform-safe key using rules
similar to QtIpcCommon::platformSafeKey() below, but using an algorithm
that is compatible with Qt 4.4 to 6.6. Additionally, the returned
QNativeIpcKey will record the input \a key so it can be included in the
string form if necessary to pass to other processes.
|
21113 |
- |
| qtipccommon.h |
|
5694 |
- |
| qtipccommon_p.h |
|
5073 |
- |