forked from CobaltFusion/DebugViewPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorLineBuffer.cpp
More file actions
47 lines (39 loc) · 1.54 KB
/
Copy pathVectorLineBuffer.cpp
File metadata and controls
47 lines (39 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "DebugViewppLib/ProcessInfo.h"
#include "DebugViewppLib/VectorLineBuffer.h"
namespace fusion {
namespace debugviewpp {
// unused argument to allow this class to be a drop-in replacement for LineBuffer
VectorLineBuffer::VectorLineBuffer(size_t /*unused*/)
{
}
void VectorLineBuffer::Add(double time, FILETIME systemTime, HANDLE handle, const std::string& message, const LogSource* pSource)
{
std::lock_guard<std::mutex> lock(m_linesMutex);
m_buffer.emplace_back(time, systemTime, handle, message, pSource);
}
void VectorLineBuffer::Add(double time, FILETIME systemTime, DWORD pid, const std::string& processName, const std::string& message, const LogSource* pSource)
{
std::lock_guard<std::mutex> lock(m_linesMutex);
m_buffer.emplace_back(time, systemTime, pid, processName, message, pSource);
}
// returning a 'const Lines&' here might be an performance improvement, however, tests reveiled no measureable difference.
Lines VectorLineBuffer::GetLines()
{
// the swap trick used here is very important to unblock the calling process asap.
m_backingBuffer.clear();
{
std::lock_guard<std::mutex> lock(m_linesMutex);
m_buffer.swap(m_backingBuffer);
}
return m_backingBuffer;
}
bool VectorLineBuffer::Empty() const
{
return m_buffer.empty();
}
} // namespace debugviewpp
} // namespace fusion