34 if (!mBuffer.create(
size))
36 if (mBuffer.error() == QSharedMemory::AlreadyExists)
38 qWarning(
"Reusing existing buffer -- this should generally not happen");
44 qWarning(
"Failed to create shared memory buffer of size %d: %s",
45 size, mBuffer.errorString().toLatin1().constData());
73 for (
int i = mCurrentBuffer + 1; i < header->
numBuffers && !found; i++)
75 if (header->
buffer[i] == 0)
78 internalRelease(
false);
82 for (
int i = 0; i < header->
numBuffers && !found; i++)
84 if (header->
buffer[i] == 0)
87 internalRelease(
false);
93 qWarning(
"Could not find an available write buffer");
108 void SharedMemoryServer::internalRelease(
bool lock)
111 if (header && mCurrentBuffer >= 0)
113 if (lock) mBuffer.lock();
116 mLastTimestamp = QDateTime::currentDateTime();
117 header->
timestamp = mLastTimestamp.toMSecsSinceEpoch();
118 if (lock) mBuffer.unlock();
125 internalRelease(
true);
138 bool success = mBuffer.attach(QSharedMemory::ReadWrite);
150 return mBuffer.detach();
160 ( onlyNew && header->
lastDone == mCurrentBuffer) )
165 if (mCurrentBuffer >= 0 && header->
buffer[mCurrentBuffer] > 0)
167 header->
buffer[mCurrentBuffer]--;
172 mTimestamp.setMSecsSinceEpoch(header->
timestamp);
187 if (header && mCurrentBuffer >= 0)
190 if (header->
buffer[mCurrentBuffer] > 0)
192 header->
buffer[mCurrentBuffer]--;