本文整理汇总了C++中SharedMemoryProcessDataHeader::GetSharedDataTotalByteCount方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedMemoryProcessDataHeader::GetSharedDataTotalByteCount方法的具体用法?C++ SharedMemoryProcessDataHeader::GetSharedDataTotalByteCount怎么用?C++ SharedMemoryProcessDataHeader::GetSharedDataTotalByteCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedMemoryProcessDataHeader
的用法示例。
在下文中一共展示了SharedMemoryProcessDataHeader::GetSharedDataTotalByteCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: id
SharedMemoryProcessDataHeader *SharedMemoryProcessDataHeader::CreateOrOpen(
LPCSTR name,
SharedMemorySharedDataHeader requiredSharedDataHeader,
SIZE_T sharedDataByteCount,
bool createIfNotExist,
bool *createdRef)
{
_ASSERTE(name != nullptr);
_ASSERTE(sharedDataByteCount != 0);
_ASSERTE(!createIfNotExist || createdRef != nullptr);
_ASSERTE(SharedMemoryManager::IsCreationDeletionProcessLockAcquired());
_ASSERTE(!SharedMemoryManager::IsCreationDeletionFileLockAcquired());
if (createdRef != nullptr)
{
*createdRef = false;
}
SharedMemoryId id(name);
struct AutoCleanup
{
bool m_acquiredCreationDeletionFileLock;
char *m_filePath;
SIZE_T m_sessionDirectoryPathCharCount;
bool m_createdFile;
int m_fileDescriptor;
bool m_acquiredFileLock;
void *m_mappedBuffer;
SIZE_T m_mappedBufferByteCount;
bool m_cancel;
AutoCleanup()
: m_acquiredCreationDeletionFileLock(false),
m_filePath(nullptr),
m_sessionDirectoryPathCharCount(0),
m_createdFile(false),
m_fileDescriptor(-1),
m_acquiredFileLock(false),
m_mappedBuffer(nullptr),
m_mappedBufferByteCount(0),
m_cancel(false)
{
}
~AutoCleanup()
{
if (m_cancel)
{
return;
}
if (m_mappedBuffer != nullptr)
{
_ASSERTE(m_mappedBufferByteCount != 0);
munmap(m_mappedBuffer, m_mappedBufferByteCount);
}
if (m_acquiredFileLock)
{
_ASSERTE(m_fileDescriptor != -1);
SharedMemoryHelpers::ReleaseFileLock(m_fileDescriptor);
}
if (m_fileDescriptor != -1)
{
SharedMemoryHelpers::CloseFile(m_fileDescriptor);
}
if (m_createdFile)
{
_ASSERTE(m_filePath != nullptr);
unlink(m_filePath);
}
if (m_sessionDirectoryPathCharCount != 0)
{
_ASSERTE(m_filePath != nullptr);
m_filePath[m_sessionDirectoryPathCharCount] = '\0';
rmdir(m_filePath);
}
if (m_acquiredCreationDeletionFileLock)
{
SharedMemoryManager::ReleaseCreationDeletionFileLock();
}
}
} autoCleanup;
SharedMemoryProcessDataHeader *processDataHeader = SharedMemoryManager::FindProcessDataHeader(&id);
if (processDataHeader != nullptr)
{
_ASSERTE(
processDataHeader->GetSharedDataTotalByteCount() ==
SharedMemorySharedDataHeader::DetermineTotalByteCount(sharedDataByteCount));
processDataHeader->IncRefCount();
return processDataHeader;
}
SharedMemoryManager::AcquireCreationDeletionFileLock();
//.........这里部分代码省略.........