From 63702ff6bdbceaaf623c7a90502d864d33c940bd Mon Sep 17 00:00:00 2001 From: rogerman Date: Mon, 30 Aug 2021 12:39:28 -0700 Subject: [PATCH] task: Change to C++03 conventions to support older compilers. Related to commit 5428763. --- desmume/src/rasterize.cpp | 6 ++--- desmume/src/utils/task.cpp | 46 +++++++++++++++++++------------------- desmume/src/utils/task.h | 6 ++--- desmume/src/wifi.cpp | 6 ++--- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index 388bf94ae..c923222e3 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -1797,13 +1797,13 @@ SoftRasterizerRenderer::SoftRasterizerRenderer() _rasterizerUnit[i].SetSLI(_threadPostprocessParam[i].startLine, _threadPostprocessParam[i].endLine, false); _rasterizerUnit[i].SetRenderer(this); + char name[16]; + snprintf(name, 16, "rasterizer %d", (int)i); #ifdef DESMUME_COCOA // The Cocoa port takes advantage of hand-optimized thread priorities // to help stabilize performance when running SoftRasterizer. - _task[i].start(false, 43); + _task[i].start(false, 43, name); #else - char name[16]; - snprintf(name, 16, "rasterizer %d", i); _task[i].start(false, 0, name); #endif } diff --git a/desmume/src/utils/task.cpp b/desmume/src/utils/task.cpp index 0e591863a..8f785e2ae 100644 --- a/desmume/src/utils/task.cpp +++ b/desmume/src/utils/task.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2016 DeSmuME team + Copyright (C) 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -85,27 +85,27 @@ Task::Impl::~Impl() shutdown(); slock_free(mutex); scond_free(condWork); -} - -void Task::Impl::start(bool spinlock, int threadPriority, const char *name) -{ - slock_lock(this->mutex); - - if (this->_isThreadRunning) { - slock_unlock(this->mutex); - return; - } - - this->workFunc = NULL; - this->workFuncParam = NULL; - this->ret = NULL; - this->exitThread = false; - this->_thread = sthread_create_with_priority(&taskProc, this, threadPriority); - this->_isThreadRunning = true; - if (name) - sthread_setname(this->_thread, name); - - slock_unlock(this->mutex); +} + +void Task::Impl::start(bool spinlock, int threadPriority, const char *name) +{ + slock_lock(this->mutex); + + if (this->_isThreadRunning) { + slock_unlock(this->mutex); + return; + } + + this->workFunc = NULL; + this->workFuncParam = NULL; + this->ret = NULL; + this->exitThread = false; + this->_thread = sthread_create_with_priority(&taskProc, this, threadPriority); + this->_isThreadRunning = true; + if (name) + sthread_setname(this->_thread, name); + + slock_unlock(this->mutex); } void Task::Impl::execute(const TWork &work, void *param) @@ -170,7 +170,7 @@ void Task::Impl::shutdown() slock_unlock(this->mutex); } -void Task::start(bool spinlock) { impl->start(spinlock, 0, nullptr); } +void Task::start(bool spinlock) { impl->start(spinlock, 0, NULL); } void Task::start(bool spinlock, int threadPriority, const char *name) { impl->start(spinlock, threadPriority, name); } void Task::shutdown() { impl->shutdown(); } Task::Task() : impl(new Task::Impl()) {} diff --git a/desmume/src/utils/task.h b/desmume/src/utils/task.h index e4053d741..a1c112593 100644 --- a/desmume/src/utils/task.h +++ b/desmume/src/utils/task.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2009-2018 DeSmuME team + Copyright (C) 2009-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,8 +29,8 @@ public: typedef void * (*TWork)(void *); // initialize task runner - void start(bool spinlock); - void start(bool spinlock, int threadPriority, const char *name = nullptr); + void start(bool spinlock); + void start(bool spinlock, int threadPriority, const char *name); //execute some work void execute(const TWork &work, void* param); diff --git a/desmume/src/wifi.cpp b/desmume/src/wifi.cpp index 5ec0cd57f..2dbc957ce 100644 --- a/desmume/src/wifi.cpp +++ b/desmume/src/wifi.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2007 Tim Seidel - Copyright (C) 2008-2018 DeSmuME team + Copyright (C) 2008-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3396,7 +3396,7 @@ bool AdhocCommInterface::Start(WifiHandler* currentWifiHandler) this->_rawPacket = (RXRawPacketData*)calloc(1, sizeof(RXRawPacketData)); #ifdef DESMUME_COCOA - this->_rxTask->start(false, 43); + this->_rxTask->start(false, 43, "wifi ad-hoc"); #else this->_rxTask->start(false, 0, "wifi ad-hoc"); #endif @@ -3670,7 +3670,7 @@ bool SoftAPCommInterface::Start(WifiHandler* currentWifiHandler) this->_rawPacket = (RXRawPacketData*)calloc(1, sizeof(RXRawPacketData)); #ifdef DESMUME_COCOA - this->_rxTask->start(false, 43); + this->_rxTask->start(false, 43, "wifi ap"); #else this->_rxTask->start(false, 0, "wifi ap"); #endif