Skip to content

Commit bc9171d

Browse files
committed
WIP: Added multithreaded scheduler
Not used right now
1 parent 287b0a6 commit bc9171d

File tree

8 files changed

+511
-6
lines changed

8 files changed

+511
-6
lines changed

src/xrEngine/Engine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern void msCreate(LPCSTR name);
1818
void CEngine::Initialize(void)
1919
{
2020
Engine.Sheduler.Initialize();
21+
Engine.Scheduler.Initialize();
2122
#ifdef DEBUG
2223
msCreate("game");
2324
#endif
@@ -26,5 +27,6 @@ void CEngine::Initialize(void)
2627
void CEngine::Destroy()
2728
{
2829
Engine.Sheduler.Destroy();
30+
Engine.Scheduler.Destroy();
2931
Engine.External.Destroy();
3032
}

src/xrEngine/Engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class ENGINE_API CEngine
1313
CEngineAPI External;
1414
CEventAPI Event;
1515
CSheduler Sheduler;
16+
XRay::Scheduler Scheduler;
1617

1718
void Initialize();
1819
void Destroy();

src/xrEngine/ISheduled.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ void ScheduledBase::shedule_Update(u32 dt)
4141
shedule.dbg_update_shedule = shedule.dbg_startframe;
4242
#endif
4343
}
44+
45+
void ScheduledBaseMT::shedule_register() { Engine.Scheduler.Register(this); }
46+
void ScheduledBaseMT::shedule_unregister() { Engine.Scheduler.Unregister(this); }

src/xrEngine/ISheduled.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
2-
#ifndef XRENGINE_ISHEDULED_H_INCLUDED
3-
#define XRENGINE_ISHEDULED_H_INCLUDED
2+
43
#include "Engine.h"
54
#include "Common/Noncopyable.hpp"
65

@@ -42,9 +41,15 @@ class ENGINE_API ScheduledBase : public virtual ISheduled, Noncopyable
4241
virtual SchedulerData& GetSchedulerData() override { return shedule; }
4342
virtual void shedule_Update(u32 dt) override;
4443
virtual shared_str shedule_Name() const override { return shared_str("unknown"); }
44+
4545
protected:
46-
void shedule_register();
47-
void shedule_unregister();
46+
virtual void shedule_register();
47+
virtual void shedule_unregister();
4848
};
4949

50-
#endif // #ifndef XRENGINE_ISHEDULED_H_INCLUDED
50+
class ENGINE_API ScheduledBaseMT : public ScheduledBase
51+
{
52+
protected:
53+
void shedule_register() override;
54+
void shedule_unregister() override;
55+
};

src/xrEngine/Stats.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ void CStats::Show()
137137
if (g_pGameLevel)
138138
g_pGameLevel->DumpStatistics(font, alertPtr);
139139
Engine.Sheduler.DumpStatistics(font, alertPtr);
140+
Engine.Scheduler.DumpStatistics(font, alertPtr);
140141
g_pGamePersistent->DumpStatistics(font, alertPtr);
141142
DumpSpatialStatistics(font, alertPtr, *g_SpatialSpace, engineTotal);
142143
DumpSpatialStatistics(font, alertPtr, *g_SpatialSpacePhysic, engineTotal);

0 commit comments

Comments
 (0)