本文整理汇总了C++中SharedMemoryProcessDataHeader::GetSharedDataHeader方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedMemoryProcessDataHeader::GetSharedDataHeader方法的具体用法?C++ SharedMemoryProcessDataHeader::GetSharedDataHeader怎么用?C++ SharedMemoryProcessDataHeader::GetSharedDataHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedMemoryProcessDataHeader
的用法示例。
在下文中一共展示了SharedMemoryProcessDataHeader::GetSharedDataHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SharedMemoryException
//.........这里部分代码省略.........
SharedMemoryManager::AcquireCreationDeletionProcessLock();
autoCleanup.m_acquiredCreationDeletionProcessLock = true;
// Create or open the shared memory
bool created;
SharedMemoryProcessDataHeader *processDataHeader =
SharedMemoryProcessDataHeader::CreateOrOpen(
name,
SharedMemorySharedDataHeader(SharedMemoryType::Mutex, SyncSystemVersion),
sizeof(NamedMutexSharedData),
createIfNotExist,
&created);
if (createdRef != nullptr)
{
*createdRef = created;
}
if (created)
{
// If the shared memory file was created, the creation/deletion file lock would have been acquired so that we can
// initialize the shared data
autoCleanup.m_acquiredCreationDeletionFileLock = true;
}
if (processDataHeader == nullptr)
{
_ASSERTE(!createIfNotExist);
return nullptr;
}
autoCleanup.m_processDataHeader = processDataHeader;
if (created)
{
// Initialize the shared data
new(processDataHeader->GetSharedDataHeader()->GetData()) NamedMutexSharedData;
}
if (processDataHeader->GetData() == nullptr)
{
#if !NAMED_MUTEX_USE_PTHREAD_MUTEX
// Create the lock files directory
char lockFilePath[SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1];
SIZE_T lockFilePathCharCount =
SharedMemoryHelpers::CopyString(lockFilePath, 0, SHARED_MEMORY_LOCK_FILES_DIRECTORY_PATH);
if (created)
{
SharedMemoryHelpers::EnsureDirectoryExists(lockFilePath, true /* isGlobalLockAcquired */);
}
// Create the session directory
lockFilePath[lockFilePathCharCount++] = '/';
SharedMemoryId *id = processDataHeader->GetId();
lockFilePathCharCount = id->AppendSessionDirectoryName(lockFilePath, lockFilePathCharCount);
if (created)
{
SharedMemoryHelpers::EnsureDirectoryExists(lockFilePath, true /* isGlobalLockAcquired */);
autoCleanup.m_lockFilePath = lockFilePath;
autoCleanup.m_sessionDirectoryPathCharCount = lockFilePathCharCount;
}
// Create or open the lock file
lockFilePath[lockFilePathCharCount++] = '/';
lockFilePathCharCount =
SharedMemoryHelpers::CopyString(lockFilePath, lockFilePathCharCount, id->GetName(), id->GetNameCharCount());
int lockFileDescriptor = SharedMemoryHelpers::CreateOrOpenFile(lockFilePath, created);
if (lockFileDescriptor == -1)
{