This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdafx.h" | |
#include "circular_buffer.h" | |
CircularBuffer::CircularBuffer(int size) | |
{ | |
init(size, false); | |
} | |
CircularBuffer::CircularBuffer(int size, bool filled) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <intrin.h> | |
#pragma intrinsic(__rdtsc) | |
#include <Windows.h> | |
int main() { | |
LARGE_INTEGER freq; | |
QueryPerformanceFrequency(&freq); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Type-safe enum class bitmasks. | |
Based on work by Andre Haupt from his blog at | |
http://blog.bitwigglers.org/using-enum-classes-as-type-safe-bitmasks/ | |
To enable enum classes to be used as bitmasks, use the ENABLE_BITMASK_OPERATORS | |
macro: | |
enum class MyBitmask { | |
None = 0b0000, | |
One = 0b0001, | |
Two = 0b0010, |

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <functional> | |
#include <type_traits> | |
#include <utility> | |
namespace util { | |
namespace detail { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <intrin.h> | |
#pragma intrinsic(__cpuid) | |
int main() { | |
int id[4]; | |
__cpuid(id, 0x15); | |
auto tscFreq = (__int64)id[2] * id[1] / id[0]; | |
printf("TSC frequency: %I64d Hz (%I64d MHz)\n", tscFreq, tscFreq / 1000000ULL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
#include <tchar.h> | |
#include <psapi.h> | |
void PrintProcessNameAndID(DWORD processID) { | |
HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processID); | |
if (NULL != hProcess) { | |
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>"); | |
DWORD size = sizeof(szProcessName) / sizeof(TCHAR); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <cstdio> | |
// A simple object lifetime checker. | |
// Use this to figure out if/when your objects are being created, destroyed, copied or moved. | |
struct LifetimeChecker { | |
LifetimeChecker() { | |
printf("LifetimeChecker()\n"); | |
} |