Files
UnrealEngineUWP/Engine/Source/Developer/Windows/LiveCodingServer/Private/External/LC_SchedulerQueue.h
Ben Marsh 0cc6e3dca6 Copying //UE4/Dev-Build to Dev-Main (//UE4/Dev-Main)
#rb none
#rnx

[CL 6631504 by Ben Marsh in Main branch]
2019-05-24 11:51:54 -04:00

45 lines
941 B
C++

// Copyright 2011-2019 Molecular Matters GmbH, all rights reserved.
#pragma once
#include "CoreTypes.h"
#include "LC_Semaphore.h"
#include "LC_CriticalSection.h"
#include <stdint.h>
namespace scheduler
{
class TaskBase;
// simple multi-producer, multi-consumer queue
class TaskQueue
{
// BEGIN EPIC MOD - Increasing task count due to hangs when enabling for all editor modules
static const unsigned int TASK_COUNT = 4096u;// 1024u;
// END EPIC MOD
static const unsigned int ACCESS_MASK = TASK_COUNT - 1u;
public:
TaskQueue(void);
// blocks when there is no more room for a task
void PushTask(TaskBase* task);
// blocks when there is no task in the queue
TaskBase* PopTask(void);
// does not block
TaskBase* TryPopTask(void);
private:
TaskBase* m_tasks[TASK_COUNT];
uint64_t m_readIndex;
uint64_t m_writeIndex;
Semaphore m_producerSema;
Semaphore m_consumerSema;
CriticalSection m_cs;
};
}