QSharedMemory Class Reference
|
Constant | Value | Description |
---|---|---|
QSharedMemory::ReadOnly | 0 | The shared memory segment is read-only. Writing to the shared memory segment is not allowed. An attempt to write to a shared memory segment created with ReadOnly causes the program to abort. |
QSharedMemory::ReadWrite | 1 | Reading and writing the shared memory segment are both allowed. |
Constant | Value | Description |
---|---|---|
QSharedMemory::NoError | 0 | No error occurred. |
QSharedMemory::PermissionDenied | 1 | The operation failed because the caller didn't have the required permissions. |
QSharedMemory::InvalidSize | 2 | A create operation failed because the requested size was invalid. |
QSharedMemory::KeyError | 3 | The operation failed because of an invalid key. |
QSharedMemory::AlreadyExists | 4 | A create() operation failed because a shared memory segment with the specified key already existed. |
QSharedMemory::NotFound | 5 | An attach() failed because a shared memory segment with the specified key could not be found. |
QSharedMemory::LockError | 6 | The attempt to lock() the shared memory segment failed because the lock was held by another process. |
QSharedMemory::OutOfResources | 7 | A create() operation failed because there was not enough memory available to fill the request. |
QSharedMemory::UnknownError | 8 | Something else happened and it was bad. |
Constructs a shared memory object with the given parent and with its key set to key. Because its key is set, its create() and attach() functions can be called.
See also setKey(), create(), and attach().
Constructs a shared memory object with the given parent. The shared memory object's key is not set by the constructor, so the shared memory object does not have an underlying shared memory segment attached. The key must be set with setKey() before create() or attach() can be used.
See also setKey().
The destructor clears the key, which forces the shared memory object to detach from its underlying shared memory segment. If this shared memory object is the last one connected to the shared memory segment, the detach() operation destroys the shared memory segment.
See also detach() and isAttached().
Attempts to attach the process to the shared memory segment identified by the key that was passed to the constructor or to a call to setKey(). The access mode is ReadWrite by default. It can also be ReadOnly. Returns true if the attach operation is successful. If false is returned, call error() to determine which error occurred. After attaching the shared memory segment, a pointer to the shared memory can be obtained by calling data().
See also isAttached(), detach(), and create().
Returns a const pointer to the contents of the shared memory segment, if one is attached. Otherwise it returns null. Remember to lock the shared memory with lock() before reading from or writing to the shared memory, and remember to release the lock with unlock() after you are done.
See also attach() and create().
Creates a shared memory segment of size bytes with the key passed to the constructor or set with setKey(), attaches to the new shared memory segment with the given access mode, and returns true. If a shared memory segment identified by the key already exists, the attach operation is not performed, and false is returned. When the return value is false, call error() to determine which error occurred.
See also error().
Returns a pointer to the contents of the shared memory segment, if one is attached. Otherwise it returns null. Remember to lock the shared memory with lock() before reading from or writing to the shared memory, and remember to release the lock with unlock() after you are done.
See also attach().
This is an overloaded member function, provided for convenience.
Detaches the process from the shared memory segment. If this was the last process attached to the shared memory segment, then the shared memory segment is released by the system, i.e., the contents are destroyed. The function returns true if it detaches the shared memory segment. If it returns false, it usually means the segment either isn't attached, or it is locked by another process.
See also attach() and isAttached().
Returns a value indicating whether an error occurred, and, if so, which error it was.
See also errorString().
Returns a text description of the last error that occurred. If error() returns an error value, call this function to get a text string that describes the error.
See also error().
Returns true if this process is attached to the shared memory segment.
See also attach() and detach().
Returns the key assigned to this shared memory. The key is the identifier used by the operating system to identify the shared memory segment. When QSharedMemory is used for interprocess communication, the key is how each process attaches to the shared memory segment through which the IPC occurs.
See also setKey().
This is a semaphore that locks the shared memory segment for access by this process. If another process has locked the segment, lock() will block until the lock is released. It returns true if it obtains the lock. It should always return true. If it returns false, it means you have a program bug. If your code calls lock() when you already have the lock, your process will block forever.
Sets a new key for this shared memory object. If key and the current key are the same, the function returns without doing anything. If the shared memory object is attached to an underlying shared memory segment, it will detach from it before setting the new key. This function does not do an attach().
See also key() and isAttached().
Returns the size of the attached shared memory segment. If no shared memory segment is attached, 0 is returned.
See also create() and attach().
Releases the lock on the shared memory segment and returns true, if the lock is currently held by this process. If the segment is not locked, or if the lock is held by another process, nothing happens and false is returned.
See also lock().
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt qtextended4.4 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com