本文整理汇总了C++中MessageBuffer::write方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageBuffer::write方法的具体用法?C++ MessageBuffer::write怎么用?C++ MessageBuffer::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageBuffer
的用法示例。
在下文中一共展示了MessageBuffer::write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendQDirInfo
void SendQDirInfo()
{
char cPacketID[2] = { VMPI_SHARED_PACKET_ID, VMPI_SUBPACKETID_DIRECTORIES };
MessageBuffer mb;
mb.write( cPacketID, 2 );
mb.write( gamedir, strlen( gamedir ) + 1 );
mb.write( qdir, strlen( qdir ) + 1 );
VMPI_SendData( mb.data, mb.getLen(), VMPI_PERSISTENT );
}
示例2: TellMasterThatWorkerStartedAWorkUnit
void TellMasterThatWorkerStartedAWorkUnit( MessageBuffer &mb, CDSInfo *pInfo, WUIndexType iWU )
{
mb.setLen( 0 );
PrepareDistributeWorkHeader( &mb, DW_SUBPACKETID_WU_STARTED );
mb.write( &iWU, sizeof( iWU ) );
VMPI_SendData( mb.data, mb.getLen(), VMPI_MASTER_ID, k_eVMPISendFlags_GroupPackets );
}
示例3: VMPI_WorkerThread
void VMPI_WorkerThread( int iThread, void *pUserData )
{
CDSInfo *pInfo = (CDSInfo*)pUserData;
CWorkerInfo *pWorkerInfo = &pInfo->m_WorkerInfo;
// Get our index for running work units
uint64 idxRunningWorkUnit = (uint64) iThread;
{
CCriticalSectionLock csLock( &pWorkerInfo->m_WorkUnitsRunningCS );
csLock.Lock();
pWorkerInfo->m_WorkUnitsRunning.ExpandWindow( idxRunningWorkUnit, ~0ull );
csLock.Unlock();
}
MessageBuffer mb;
PrepareDistributeWorkHeader( &mb, DW_SUBPACKETID_WU_RESULTS );
MessageBuffer mbStartedWorkUnit; // Special messagebuffer used to tell the master when we started a work unit.
while ( g_iMasterFinishedDistributeWorkCall < g_iCurDSInfo && !g_bVMPIEarlyExit )
{
WUIndexType iWU;
// Quit out when there are no more work units.
if ( !g_pCurDistributorWorker->GetNextWorkUnit( &iWU ) )
{
// Wait until there are some WUs to do. This should probably use event handles.
VMPI_Sleep( 10 );
continue;
}
CCriticalSectionLock csLock( &pWorkerInfo->m_WorkUnitsRunningCS );
csLock.Lock();
// Check if this WU is not running
WUIndexType const *pBegin = &pWorkerInfo->m_WorkUnitsRunning.Get( 0ull ), *pEnd = pBegin + pWorkerInfo->m_WorkUnitsRunning.PastVisibleIndex();
WUIndexType const *pRunningWu = GenericFind( pBegin, pEnd, iWU );
if ( pRunningWu != pEnd )
continue;
// We are running it
pWorkerInfo->m_WorkUnitsRunning.Get( idxRunningWorkUnit ) = iWU;
csLock.Unlock();
// Process this WU and send the results to the master.
mb.setLen( 4 );
mb.write( &iWU, sizeof( iWU ) );
// Set the current WU for the stats database.
if ( iThread >= 0 && iThread < 4 )
{
g_ThreadWUs[iThread] = iWU;
}
// Tell the master we're starting on this WU.
TellMasterThatWorkerStartedAWorkUnit( mbStartedWorkUnit, pInfo, iWU );
pWorkerInfo->m_pProcessFn( iThread, iWU, &mb );
g_pCurDistributorWorker->NoteLocalWorkUnitCompleted( iWU );
VMPI_SendData( mb.data, mb.getLen(), VMPI_MASTER_ID, /*k_eVMPISendFlags_GroupPackets*/0 );
// Flush grouped packets every once in a while.
//VMPI_FlushGroupedPackets( 1000 );
}
if ( g_iVMPIVerboseLevel >= 1 )
Msg( "Worker thread exiting.\n" );
}