mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Pass function objects through const references.
This commit is contained in:
@@ -11,7 +11,7 @@ class RunQueue;
|
||||
class Backend
|
||||
{
|
||||
public:
|
||||
Backend( const char* title, std::function<void()> redraw, RunQueue* mainThreadTasks );
|
||||
Backend( const char* title, const std::function<void()>& redraw, RunQueue* mainThreadTasks );
|
||||
~Backend();
|
||||
|
||||
void Show();
|
||||
|
||||
@@ -60,7 +60,7 @@ static void glfw_window_iconify_callback( GLFWwindow*, int iconified )
|
||||
}
|
||||
|
||||
|
||||
Backend::Backend( const char* title, std::function<void()> redraw, RunQueue* mainThreadTasks )
|
||||
Backend::Backend( const char* title, const std::function<void()>& redraw, RunQueue* mainThreadTasks )
|
||||
{
|
||||
glfwSetErrorCallback( glfw_error_callback );
|
||||
if( !glfwInit() ) exit( 1 );
|
||||
|
||||
@@ -630,7 +630,7 @@ static void SetupCursor()
|
||||
s_cursorY = cursor->images[0]->hotspot_y / s_maxScale;
|
||||
}
|
||||
|
||||
Backend::Backend( const char* title, std::function<void()> redraw, RunQueue* mainThreadTasks )
|
||||
Backend::Backend( const char* title, const std::function<void()>& redraw, RunQueue* mainThreadTasks )
|
||||
{
|
||||
s_redraw = redraw;
|
||||
s_mainThreadTasks = mainThreadTasks;
|
||||
|
||||
@@ -72,7 +72,7 @@ static const char* GetOsInfo()
|
||||
return buf;
|
||||
}
|
||||
|
||||
void HttpRequest( const char* server, const char* resource, int port, std::function<void(int, char*)> cb )
|
||||
void HttpRequest( const char* server, const char* resource, int port, const std::function<void(int, char*)>& cb )
|
||||
{
|
||||
tracy::Socket sock;
|
||||
if( !sock.ConnectBlocking( server, port ) ) return;
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
void HttpRequest( const char* server, const char* resource, int port, std::function<void(int, char*)> cb );
|
||||
void HttpRequest( const char* server, const char* resource, int port, const std::function<void(int, char*)>& cb );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@ RunQueue::RunQueue()
|
||||
{
|
||||
}
|
||||
|
||||
void RunQueue::Queue( std::function<void()> cb, bool forceDelay )
|
||||
void RunQueue::Queue( const std::function<void()>& cb, bool forceDelay )
|
||||
{
|
||||
if( !forceDelay && std::this_thread::get_id() == m_mainThread )
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ class RunQueue
|
||||
public:
|
||||
RunQueue();
|
||||
|
||||
void Queue( std::function<void()> cb, bool forceDelay = false );
|
||||
void Queue( const std::function<void()>& cb, bool forceDelay = false );
|
||||
void Run();
|
||||
|
||||
private:
|
||||
|
||||
@@ -114,7 +114,7 @@ static void AttentionCallback()
|
||||
|
||||
static void DrawContents();
|
||||
|
||||
void RunOnMainThread( std::function<void()> cb, bool forceDelay = false )
|
||||
static void RunOnMainThread( const std::function<void()>& cb, bool forceDelay = false )
|
||||
{
|
||||
mainThreadTasks.Queue( cb, forceDelay );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user