chore: checkpoint before CaptureDemo SDK migration
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#ifndef _SEMAPHORE_H_
|
||||
#define _SEMAPHORE_H_
|
||||
#include <memory>
|
||||
class Semaphore
|
||||
{
|
||||
public:
|
||||
Semaphore(unsigned long count = 0) : count_(count) {}
|
||||
|
||||
Semaphore(const Semaphore &) = delete;
|
||||
|
||||
Semaphore &operator=(const Semaphore &) = delete;
|
||||
|
||||
void signal()
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx_);
|
||||
++count_;
|
||||
}
|
||||
cv_.notify_one();
|
||||
}
|
||||
|
||||
void wait()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx_);
|
||||
cv_.wait(lock, [=]() {
|
||||
return count_ > 0;
|
||||
});
|
||||
--count_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex mtx_;
|
||||
std::condition_variable cv_;
|
||||
unsigned long count_;
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "utils.h"
|
||||
|
||||
BYTE* Utils::allocate_buffer(size_t size, size_t alignment)
|
||||
{
|
||||
if (size == 0)
|
||||
{
|
||||
size = 4;
|
||||
}
|
||||
|
||||
if (alignment == 0)
|
||||
{
|
||||
SYSTEM_INFO sys_info;
|
||||
GetSystemInfo(&sys_info);
|
||||
alignment = sys_info.dwPageSize;
|
||||
}
|
||||
|
||||
return (BYTE *)_aligned_malloc(size, alignment);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef UTILS_H_
|
||||
#define UTILS_H_
|
||||
#include <Windows.h>
|
||||
class Utils {
|
||||
public:
|
||||
Utils(){};
|
||||
public:
|
||||
static BYTE* allocate_buffer(size_t size, size_t alignment);
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user