本文整理汇总了C++中SharedMemoryProcessDataHeader::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedMemoryProcessDataHeader::GetId方法的具体用法?C++ SharedMemoryProcessDataHeader::GetId怎么用?C++ SharedMemoryProcessDataHeader::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedMemoryProcessDataHeader
的用法示例。
在下文中一共展示了SharedMemoryProcessDataHeader::GetId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddProcessDataHeader
void SharedMemoryManager::AddProcessDataHeader(SharedMemoryProcessDataHeader *processDataHeader)
{
_ASSERTE(processDataHeader != nullptr);
_ASSERTE(IsCreationDeletionProcessLockAcquired());
_ASSERTE(processDataHeader->GetNextInProcessDataHeaderList() == nullptr);
_ASSERTE(FindProcessDataHeader(processDataHeader->GetId()) == nullptr);
processDataHeader->SetNextInProcessDataHeaderList(s_processDataHeaderListHead);
s_processDataHeaderListHead = processDataHeader;
}
示例2:
SharedMemoryProcessDataHeader *SharedMemoryManager::FindProcessDataHeader(SharedMemoryId *id)
{
_ASSERTE(IsCreationDeletionProcessLockAcquired());
// TODO: Use a hash table
for (SharedMemoryProcessDataHeader *current = s_processDataHeaderListHead;
current != nullptr;
current = current->GetNextInProcessDataHeaderList())
{
if (current->GetId()->Equals(id))
{
return current;
}
}
return nullptr;
}
示例3: SharedMemoryException
//.........这里部分代码省略.........
// 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)
{
_ASSERTE(!created);
if (createIfNotExist)
{
throw SharedMemoryException(static_cast<DWORD>(SharedMemoryError::IO));
}
return nullptr;
}
autoCleanup.m_createdLockFile = created;
autoCleanup.m_lockFileDescriptor = lockFileDescriptor;
#endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX
// Create the process data
void *processDataBuffer = SharedMemoryHelpers::Alloc(sizeof(NamedMutexProcessData));
AutoFreeBuffer autoFreeProcessDataBuffer(processDataBuffer);
NamedMutexProcessData *processData =
new(processDataBuffer)
NamedMutexProcessData(
processDataHeader
#if !NAMED_MUTEX_USE_PTHREAD_MUTEX
,
lockFileDescriptor
#endif // !NAMED_MUTEX_USE_PTHREAD_MUTEX
);
autoFreeProcessDataBuffer.Cancel();
processDataHeader->SetData(processData);
// If the mutex was created and if requested, acquire the lock initially while holding the creation/deletion locks
if (created && acquireLockIfCreated)
{
MutexTryAcquireLockResult tryAcquireLockResult = processData->TryAcquireLock(0);
_ASSERTE(tryAcquireLockResult == MutexTryAcquireLockResult::AcquiredLock);
}
}
autoCleanup.m_cancel = true;
return processDataHeader;
}