mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
* Only run '_DownloadPlaylists_f()' in the main thread, schedule for next frame if we aren't in the main thread. (this should fix crash cases related to disconnecting from the game). * Locked read/write to CBrowser members (thread for obtaining the server list is detached, but once the 'slow' post operation in this thread is complete, mutex lock is acquired (locking the render thread if the browser is active) to set the string members of CBrowser, this operation is very fast as we only set the string and the color after the http post operation (this never caused a crash, but the behavior without any lock mechanism is technically undefined regardless). * Obtain the host name dynamically from the ConVar 'pylon_matchmaking_hostname' (atomic operation). Initial approach was deleting the whole master server pointer just to construct a new httpclient object..
31 lines
1003 B
C++
31 lines
1003 B
C++
#ifndef TIER0_FRAMETASK_H
|
|
#define TIER0_FRAMETASK_H
|
|
|
|
#include "public/iframetask.h"
|
|
|
|
//=============================================================================//
|
|
// This class is set up to run before each frame (main thread).
|
|
// Commited tasks are scheduled to execute after 'i' frames.
|
|
// ----------------------------------------------------------------------------
|
|
// A usecase for scheduling tasks in the main thread would be (for example)
|
|
// calling 'KeyValues::ParsePlaylists(...)' from the render thread.
|
|
//=============================================================================//
|
|
class CFrameTask : public IFrameTask
|
|
{
|
|
public:
|
|
virtual ~CFrameTask() {}
|
|
virtual void RunFrame();
|
|
virtual bool IsFinished() const;
|
|
|
|
void Dispatch(std::function<void()> functor, int frames);
|
|
|
|
private:
|
|
mutable std::mutex m_Mutex;
|
|
std::list<DelayedCall_s> m_DelayedCalls;
|
|
};
|
|
|
|
extern std::list<IFrameTask*> g_FrameTasks;
|
|
extern CFrameTask* g_TaskScheduler;
|
|
|
|
#endif // TIER0_FRAMETASK_H
|