mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Allow sync HTTP fetches to be interrupted to fix hanging (#14412)
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
This commit is contained in:
@@ -62,6 +62,9 @@ DEALINGS IN THE SOFTWARE.
|
||||
// See https://msdn.microsoft.com/en-us/library/hh920601.aspx#thread__native_handle_method
|
||||
#define win32_native_handle() ((HANDLE) getThreadHandle())
|
||||
|
||||
thread_local Thread *current_thread = nullptr;
|
||||
|
||||
|
||||
Thread::Thread(const std::string &name) :
|
||||
m_name(name),
|
||||
m_request_stop(false),
|
||||
@@ -177,6 +180,8 @@ void Thread::threadProc(Thread *thr)
|
||||
thr->m_kernel_thread_id = thread_self();
|
||||
#endif
|
||||
|
||||
current_thread = thr;
|
||||
|
||||
thr->setName(thr->m_name);
|
||||
|
||||
g_logger.registerThread(thr->m_name);
|
||||
@@ -197,6 +202,12 @@ void Thread::threadProc(Thread *thr)
|
||||
}
|
||||
|
||||
|
||||
Thread *Thread::getCurrentThread()
|
||||
{
|
||||
return current_thread;
|
||||
}
|
||||
|
||||
|
||||
void Thread::setName(const std::string &name)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
|
@@ -119,6 +119,11 @@ public:
|
||||
*/
|
||||
bool setPriority(int prio);
|
||||
|
||||
/*
|
||||
* Returns the thread object of the current thread if it exists.
|
||||
*/
|
||||
static Thread *getCurrentThread();
|
||||
|
||||
/*
|
||||
* Sets the currently executing thread's name to where supported; useful
|
||||
* for debugging.
|
||||
|
Reference in New Issue
Block a user