Remove more unused things from CryCommon and CrySystem. (#709)

Lots of unrelated removals, I basically tried to remove everything exposed via gEnv that isn't used anymore, and following the threads found a few other things to remove also.
This commit is contained in:
bosnichd
2021-05-12 08:30:15 -06:00
committed by GitHub
parent f9fb61cc5d
commit 7cec2d8b07
198 changed files with 29 additions and 28558 deletions
@@ -1,207 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
//
// IBackgroundScheduleManager manages schedule of group of larger operations that should be run in sequence
//
// Schedules are derived from IBackgroundSchedule and consist of a list of IBackgroundScheduleItems.
// Each schedule item is executed IN ORDER for the previous item to complete first.
// Each IBackgroundScheduleItems consists of list of user defined work via IBackgroundScheduleItemsWork classes.
// Each schedule item work is executed IN PARALEL (they are all started when the item starts).
//
// Whenever a work item fails to complete the other work items are stopped, the schedule item is marked as "failed"
// and so is the whole schedule.
//
// All logic is performed on the main thread although schedule items are free to use threads.
// It is recommended to use IBackgroundTaskManager for dispatching a task list for every schedule work item.
//
// All objects in the schedule system are reference counted.
//
// State of the whole schedule
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDSCHEDULEMANAGER_H
#define CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDSCHEDULEMANAGER_H
#pragma once
enum EScheduleState
{
// Item has not started yet but is on the list
eScheduleState_Pending,
// We are processing this item
eScheduleState_Processing,
// We are stopping the schedule
eSccheduleState_Stopping,
// Schedule item has failed
eScheduleState_Failed,
// Schedule item was canceled
eScheduleState_Canceled,
// Schedule item has completed it's work
eScheduleState_Completed,
};
// State of the single schedule item
enum EScheduleItemState
{
// Item has not started yet but is on the list
eScheduleItemState_Pending,
// We are processing this item
eScheduleItemState_Processing,
// We are stopping this item
eScheduleItemState_Stopping,
// Schedule item has failed
eScheduleItemState_Failed,
// Schedule item has completed it's work
eScheduleItemState_Completed,
};
// Work item status
enum EScheduleWorkItemStatus
{
// Work is still not finished
eScheduleWorkItemStatus_NotFinished,
// Work has failed
eScheduleWorkItemStatus_Failed,
// Work has finished
eScheduleWorkItemStatus_Finished,
};
struct IBackgroundScheduleItemWork
{
// Get human readable description
virtual const char* GetDescription() const = 0;
// Get work item progress
virtual float GetProgress() const = 0;
// Called when the schedule item containing this work piece has started
// If the work cannot be started for any reason return false.
virtual bool OnStart() = 0;
// Called when the schedule item containing this work piece has been canceled or failed externally
// Not called when schedule item completed without errors.
// If the work cannot be stopped this frame return false.
virtual bool OnStop() = 0;
// Called every frame to advance and check the work state
// Should return one of the EBackgroundScheduleWorkItemStatus value
virtual EScheduleWorkItemStatus OnUpdate() = 0;
// Reference counting
virtual void AddRef() = 0;
virtual void Release() = 0;
protected:
virtual ~IBackgroundScheduleItemWork() {};
};
struct IBackgroundScheduleItem
{
// Get name of the schedule (debug & display)
virtual const char* GetDescription() const = 0;
// Get interal state
virtual EScheduleItemState GetState() const = 0;
// Get overall progress of this schedule item
virtual const float GetProgress() const = 0;
// Get number of work items in this schedule item
virtual const uint32 GetNumWorkItems() const = 0;
// Get n-th work item from the schedule item
virtual IBackgroundScheduleItemWork* GetWorkItem(const uint32 index) const = 0;
// Add work item to the schedule item
virtual void AddWorkItem(IBackgroundScheduleItemWork* pWork) = 0;
// Reference counting
virtual void AddRef() = 0;
virtual void Release() = 0;
protected:
virtual ~IBackgroundScheduleItem() {};
};
struct IBackgroundSchedule
{
// Get name of the schedule (debug & display)
virtual const char* GetDescription() const = 0;
// Get overall progress of the whole schedule
virtual float GetProgress() const = 0;
// Get item being currently processed
virtual IBackgroundScheduleItem* GetProcessedItem() const = 0;
// Get number of items in the schedule
virtual const uint32 GetNumItems() const = 0;
// Get single schedule item
virtual IBackgroundScheduleItem* GetItem(const uint32 index) const = 0;
// Get schedule item
virtual EScheduleState GetState() const = 0;
// Cancel the whole schedule
virtual void Cancel() = 0;
// Is the schedule canceled ?
virtual bool IsCanceled() const = 0;
// Add schedule item at the end of the list
virtual void AddItem(IBackgroundScheduleItem* pItem) = 0;
// Reference counting
virtual void AddRef() = 0;
virtual void Release() = 0;
protected:
virtual ~IBackgroundSchedule() {};
};
struct IBackgroundScheduleManager
{
virtual ~IBackgroundScheduleManager() {};
// Create empty schedule
virtual IBackgroundSchedule* CreateSchedule(const char* szName) = 0;
// Create empty schedule item
virtual IBackgroundScheduleItem* CreateScheduleItem(const char* szName) = 0;
// Issue a schedule to the list (will start processing it)
virtual void SubmitSchedule(IBackgroundSchedule* pSchedule) = 0;
// Get number of schedules on the list
virtual const uint32 GetNumSchedules() const = 0;
// Get n-th schedule
virtual IBackgroundSchedule* GetSchedule(const uint32 index) const = 0;
// Advance work on the schedules
virtual void Update() = 0;
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDSCHEDULEMANAGER_H
@@ -1,230 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
//
// IBackgroundTaskManager runs background tasks in worker thread.
//
// Tasks are derived from IBackgroundTask. Each task is split in two parts for:
// Work - done in background thread.
// Finalize - called afterward in main thread to apply results.
//
// Task objects are reference counted. Task manager will hold its own reference to the task object
// for as long as the task is pending or being executed. If you want to keep the task object around
// in your code you will have to call AddRef() and Release() on the task object by yourself so there
// will be an extra reference to the task object held by your code.
//
// Work returns the state of the task. Task can be resumed, then the Work
// method will be called again. Other tasks can work between calls to Work.
// It is possible to Cancel task. Work method is not invoked any more for
// Canceled tasks.
//
#ifndef CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDTASKMANAGER_H
#define CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDTASKMANAGER_H
#pragma once
enum ETaskPriority
{
eTaskPriority_FileUpdateFinal,
eTaskPriority_BackgroundScan,
eTaskPriority_FileUpdate,
eTaskPriority_RealtimePreview
};
// Result code returned by task Work() function
enum ETaskResult
{
// Task has not yet completed, add it back to the task queue with the same parameters (priority and thread mask)
eTaskResult_Resume,
// Task has completed without errors (it's assumed that the result the task was supposed to achieve was achieved)
eTaskResult_Completed,
// Task was canceled
eTaskResult_Canceled,
// Task has failed to complete it's work
eTaskResult_Failed,
};
// Internal task tracking state
enum ETaskState
{
// Task was just created.
eTaskState_Created,
// Task was scheduled to be executed in the future.
eTaskState_Scheduled,
// Task was added to the task queue and is waiting for it's time to be executed.
eTaskState_Pending,
// Task is being processed right now.
eTaskState_Working,
// Task was canceled before it has finished (indication that TaskManager has seen the Cancel() call).
eTaskState_Canceled,
// Task Work() function was called but it ended with an error code.
eTaskState_Failed,
// Task has completed it's Work() function without errors.
eTaskState_Completed,
};
// Thread mask controls which on which threads given task can be executed.
enum ETaskThreadMask
{
// Task can run only on the IO thread (default)
// There is only one IO thread so all task with this flag are run in a sequence.
eTaskThreadMask_IO,
// Task can run on any thread (concurrent tasks allowed)
// There can be many threads with this mask so there's no limit on the concurrent task count.
eTaskThreadMask_Any,
eTaskThreadMask_COUNT,
};
struct IBackgroundTask
{
public:
IBackgroundTask()
: m_bCanceled(false)
, m_state(eTaskState_Created)
, m_progress(-1.0f)
, m_refCount(0)
, m_bFailReported(false)
{}
void Cancel()
{
m_bCanceled = true;
}
bool IsCanceled() const
{
return m_bCanceled;
}
bool HasFinished() const
{
return (m_state == eTaskState_Canceled) ||
(m_state == eTaskState_Completed) ||
(m_state == eTaskState_Failed);
}
bool HasFinishedWithoutError() const
{
return (m_state == eTaskState_Completed);
}
ETaskState GetState() const
{
return m_state;
}
void SetState(ETaskState state)
{
m_state = state;
}
float GetProgress() const
{
return m_progress;
}
int AddRef()
{
return CryInterlockedIncrement(&m_refCount);
}
int Release()
{
const int nCount = CryInterlockedDecrement(&m_refCount);
assert(nCount >= 0);
if (nCount == 0)
{
Delete();
}
else if (nCount < 0)
{
assert(0);
CryFatalError("Deleting Reference Counted Object Twice");
}
return nCount;
}
bool FailReported() const{ return m_bFailReported; }
// Get the user readable description (name) of this task, used for logging
virtual const char* Description() const { return ""; }
// Get the user readable error message (in case when the task fails), used for logging the errors
virtual const char* ErrorMessage() const { return ""; }
// Called from main thread after task is completed just before the task gets destroyed
virtual void Finalize() {}
// Since there's a possibility that task object were created using different allocator
// we need a way to delete the task object once we are done with it
virtual void Delete() = 0;
// Invoked from worker thread, actual work is done here
virtual ETaskResult Work() = 0;
protected:
void SetProgress(float progress) { m_progress = progress; }
void SetFailReported() { m_bFailReported = true; }
// destructor is hidden to indicate that we should use Release() method
virtual ~IBackgroundTask() {}
private:
volatile int m_refCount;
ETaskState m_state;
float m_progress;
bool m_bCanceled;
bool m_bFailReported;
};
struct IBackgroundTaskManagerListener
{
virtual ~IBackgroundTaskManagerListener() {}
virtual void OnBackgroundTaskAdded(const char* description) = 0;
virtual void OnBackgroundTaskCompleted(ETaskResult taskResult, const char* description) = 0;
};
struct IBackgroundTaskManager
{
enum
{
BACKGROUND_TASK_ID_INVALID = 0
};
virtual ~IBackgroundTaskManager() {}
// Add task to the queue with given priority and thread mask
virtual void AddTask(IBackgroundTask* pTask, ETaskPriority priority, ETaskThreadMask threadMask) = 0;
// Schedule task to be executed in the future
virtual void ScheduleTask(IBackgroundTask* pTask, ETaskPriority priority, int delayMilliseconds, ETaskThreadMask threadMask) = 0;
virtual void AddListener(IBackgroundTaskManagerListener* pListener, const char* name) = 0;
virtual void RemoveListener(IBackgroundTaskManagerListener* pListener) = 0;
};
#endif // CRYINCLUDE_EDITOR_INCLUDE_IBACKGROUNDTASKMANAGER_H