Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TrackedActivity.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Templates/Function.h"
7#include "Templates/SharedPointer.h"
8
9/**
10* Enum to specify status light for an activity
11* Is used by the new console to show a colored dot in front of the tracked activity entry
12*/
14{
15 None,
16 Red,
17 Yellow,
18 Green,
19 Inherit,
20};
21
22/**
23 * Tracked Activity is used to be able to visualize on a semi-high level what is going on in the process.
24 * It is very useful when wanting to show the status of online, or if the runtime is waiting on loading something
25 * When new console is enabled tracked activities show at the bottom of the window under the log
26 * Tracked Activities can be created/updated/destroyed on multiple threads
27 */
29{
30public:
31 /**
32 * Enum to specify status type of activity
33 * In the new console, 'Activity' will make sure tracked activity appears to the left of the window
34 * 'Info' appears to the right and use less width. Typically use 'Info' for things that are more static
35 */
36 enum class EType
37 {
39 Info,
40 Debug,
41 };
42
43 using ELight = ETrackedActivityLight;
44
45 /** Ctor
46 * @param Name Name of tracked activity
47 * @param Status Initial status of tracked activity
48 * @param Light for the activity. Will show as a dot in front of activity in console
49 * @param Type Decides where activity information show in console. Activity is to the left, Info to the right
50 * @param SortValue Decides in what order within type the activity will show in console. Lower value means earlier
51 */
52 FTrackedActivity(const TCHAR* Name, const TCHAR* Status = TEXT(""), ELight Light = ELight::None, EType Type = EType::Activity, int32 SortValue = 100);
53
54 /** Dtor */
56
57
58 /**
59 * Pushes new status on to tracked activity, will require a pop to get back to previous status
60 * ShowParent can be used to make sure Status of parent is visible in front of status of pushed scope.
61 */
62 uint32 Push(const TCHAR* Status, bool bShowParent = false, ELight Light = ELight::Inherit);
63 void Pop();
64
65 /** Updates status. If Index is ~0u entry at top of stack will be updated (which is the one showing) */
66 void Update(const TCHAR* Status, uint32 Index = ~0u);
67 void Update(const TCHAR* Status, ELight Light, uint32 Index = ~0u);
68 void Update(ELight Light, uint32 Index = ~0u);
69
70
71 /**
72 * Process Engine Activity. General status of the Engine. Used by Engine initialization etc.
73 * By default, status light will stay yellow until main threads hits Tick update, then it turns green.
74 */
76
77 /** I/O Activity.Shows current I / O operation.If plugin / game have their own I / O, scopes will need to be manually added */
79
80
81
82 struct FInfo
83 {
84 const TCHAR* Name;
85 const TCHAR* Status;
86 ELight Light; // Can not be "Inherit"
88 int32 SortValue;
89 uint32 Id; // Unique Id for Activity (Is thread safe counter starting at 1)
90 };
91
92 /**
93 * Traverses all FTrackedActivities in the order they were added.
94 */
95 static void TraverseActivities(const TFunction<void(const FInfo& Info)>& Func);
96
97
98
99 /** Enum used for Event listener to identify type of activity change */
100 enum class EEvent : int32
101 {
102 Added = 1,
103 Removed = 2,
104 Changed = 3
105 };
106
107 /** Register listener that can track adds, removes and changes when they happen.
108 * Listener will be called from the same thread as the event happens, so make sure listener is threadsafe.
109 */
110 static void RegisterEventListener(TUniqueFunction<void(EEvent Event, const FInfo& Info)>&& Func, uint32 MaxDepth = ~0u);
111
112
113private:
116
117 void* Internal;
118};
119
120
121/**
122* RAII class that calls push in ctor and pop in dtor.
123*/
125{
126public:
127 FTrackedActivityScope(FTrackedActivity& Activity, const TCHAR* Status, bool bShowParent = false, FTrackedActivity::ELight Light = FTrackedActivity::ELight::Inherit);
129private:
131};
132
133
134/**
135* Enabled tracking of IO
136*/
137#ifndef UE_ENABLE_TRACKED_IO
139 #define UE_ENABLE_TRACKED_IO 0
140 #define UE_SCOPED_IO_ACTIVITY(...)
141 #else
142 #define UE_ENABLE_TRACKED_IO 1
143 #define UE_SCOPED_IO_ACTIVITY(...) FTrackedActivityScope ANONYMOUS_VARIABLE(IOActivity_)(FTrackedActivity::GetIOActivity(), __VA_ARGS__);
144 #endif
145#endif
#define UE_BUILD_SHIPPING
Definition Build.h:4
#define TEXT(x)
Definition Platform.h:1108
ETrackedActivityLight
FTrackedActivity(const FTrackedActivity &O)=delete
static FTrackedActivity & GetEngineActivity()
void Update(const TCHAR *Status, uint32 Index=~0u)
static void RegisterEventListener(TUniqueFunction< void(EEvent Event, const FInfo &Info)> &&Func, uint32 MaxDepth=~0u)
static void TraverseActivities(const TFunction< void(const FInfo &Info)> &Func)
uint32 Push(const TCHAR *Status, bool bShowParent=false, ELight Light=ELight::Inherit)
static FTrackedActivity & GetIOActivity()
FTrackedActivity(const TCHAR *Name, const TCHAR *Status=TEXT(""), ELight Light=ELight::None, EType Type=EType::Activity, int32 SortValue=100)
void Update(const TCHAR *Status, ELight Light, uint32 Index=~0u)
void Update(ELight Light, uint32 Index=~0u)
FTrackedActivity & operator=(const FTrackedActivity &O)=delete
FTrackedActivity & Activity
FTrackedActivityScope(FTrackedActivity &Activity, const TCHAR *Status, bool bShowParent=false, FTrackedActivity::ELight Light=FTrackedActivity::ELight::Inherit)