SpinLockHolder _slh(&m_lock);
// Naively walk the circular buffer, writing the event stream in timestamp order.
+ m_numEventsWritten = 0;
while(true)
{
EventPipeEventInstance *pOldestInstance = NULL;
// Write the oldest event.
pFile->WriteEvent(*pOldestInstance);
-#ifdef _DEBUG
- m_numEventsWritten++;
-#endif // _DEBUG
+ m_numEventsWritten++;
// Pop the event from the buffer.
pOldestContainingList->PopNextEvent(stopTimeStamp);
}
+
+ if (m_numEventsWritten > 0)
+ pFile->Flush();
}
EventPipeEventInstance* EventPipeBufferManager::GetNextEvent()
unsigned int m_numBuffersLeaked;
Volatile<LONG> m_numEventsStored;
Volatile<LONG> m_numEventsDropped;
- LONG m_numEventsWritten;
#endif // _DEBUG
+ unsigned long m_numEventsWritten;
// Allocate a new buffer for the specified thread.
// This function will store the buffer in the thread's buffer list for future use and also return it here.
// A NULL return value means that a buffer could not be allocated.
WriteToBlock(instance, metadataId);
}
+void EventPipeFile::Flush()
+{
+ // Write existing buffer to the stream/file regardless of whether it is full or not.
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_ANY;
+ }
+ CONTRACTL_END;
+ m_pSerializer->WriteObject(m_pBlock); // we write current block to the disk, whether it's full or not
+ m_pBlock->Clear();
+}
+
void EventPipeFile::WriteEnd()
{
CONTRACTL
~EventPipeFile();
void WriteEvent(EventPipeEventInstance &instance);
+ void Flush();
const char *GetTypeName() override
{
MODE_ANY;
}
CONTRACTL_END;
-
m_pFileStream = new CFileStream();
if (FAILED(m_pFileStream->OpenForWrite(outputFilePath)))
{
// the enumeration has a specific set of values to keep it compatible with consumer library
// it's sibling is defined in https://github.com/Microsoft/perfview/blob/10d1f92b242c98073b3817ac5ee6d98cd595d39b/src/FastSerialization/FastSerialization.cs#L2295
-enum class FastSerializerTags : BYTE
+enum class FastSerializerTags : uint8_t
{
Error = 0, // To improve debugabilty, 0 is an illegal tag.
NullReference = 1, // Tag for a null object forwardReference.