diff --git a/lib/TaskSystem.h b/lib/TaskSystem.h deleted file mode 100644 index ec2706bb..00000000 --- a/lib/TaskSystem.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . - ---- HISTORICAL COMMENTS FOLLOW --- - - * $Logfile: /DescentIII/Main/lib/TaskSystem.h $ - * $Revision: 3 $ - * $Date: 9/14/98 4:02p $ - * $Author: Samir $ - * - * Task manager - * - * $Log: /DescentIII/Main/lib/TaskSystem.h $ - * - * 3 9/14/98 4:02p Samir - * allow variable lengths of blocking for tasks. - * - * 2 8/10/98 5:54p Samir - * added mutexes. - * - * 1 5/23/97 4:07p Samir - * Initial revision. - * - * $NoKeywords: $ - */ - -#ifndef TASKSYSTEM_H -#define TASKSYSTEM_H - -#include "pstypes.h" - -enum tTaskPriority { TASKPRIORITY_HIGHEST, TASKPRIORITY_NORMAL, TASKPRIORITY_LOWEST }; - -// Since this system handles concepts such as multitasking, and the such, -// we will define the event structures differently, since different systems -// handle multitasking differently. - -class osEvent { -public: -#if defined(WIN32) - void *event_os_handle; // this is the Win32 Event Handle -#endif // WIN32 - -public: - osEvent(char *name); - ~osEvent(); - - bool error() const; // reports error - - void signal(); // signal the event so blocking can stop - void clear(); // clear the event so blocking can continue - bool block(int timeout = -1); // block until signaled (-1 = full blocking, else time in ms to block) -}; - -class osTask { -public: -#if defined(WIN32) - void *task_os_handle; // This is the Win32 Thread Handle -#endif // WIN32 - -public: - osTask(unsigned (*func)(void *), tTaskPriority priority, void *parm = NULL); - ~osTask(); - - bool error() const; // reports error - - void suspend(); // suspends task - void resume(); // resumes task -}; - -#endif diff --git a/linux/lnxcon_raw.cpp b/linux/lnxcon_raw.cpp index 08f5a74f..ae846013 100644 --- a/linux/lnxcon_raw.cpp +++ b/linux/lnxcon_raw.cpp @@ -45,7 +45,6 @@ #include #include "AppConsole.h" -#include "TaskSystem.h" #include "ddio_common.h" static char *Con_raw_read_buf = nullptr; // The next buffer of text from user input diff --git a/stream_audio/streamaudio.h b/stream_audio/streamaudio.h index 077ba0aa..e0cf3718 100644 --- a/stream_audio/streamaudio.h +++ b/stream_audio/streamaudio.h @@ -139,9 +139,7 @@ #define __STREAMAUDIO_H_ #include "adecode.h" - #include "ssl_lib.h" -#include "TaskSystem.h" void *AudioStreamCB(void *user_data, int handle, int *size); int ADecodeFileRead(void *data, void *buf, uint32_t qty); diff --git a/win32/CMakeLists.txt b/win32/CMakeLists.txt index ec3b6e24..a4b646a4 100644 --- a/win32/CMakeLists.txt +++ b/win32/CMakeLists.txt @@ -3,7 +3,6 @@ set(CPPS wincon.cpp WinController.cpp windata.cpp - wintask.cpp ) add_library(win32 STATIC ${CPPS}) diff --git a/win32/wincon.cpp b/win32/wincon.cpp index 5ff4f747..d13d76ae 100644 --- a/win32/wincon.cpp +++ b/win32/wincon.cpp @@ -64,18 +64,14 @@ * $NoKeywords: $ */ +#include #include #include +#include +#include #include "Application.h" #include "AppConsole.h" -#include "TaskSystem.h" - -#include -#include -#include - -#include #define CON_SCROLL_ROWS 25 #define CON_SCROLL_COLS 80 diff --git a/win32/wintask.cpp b/win32/wintask.cpp deleted file mode 100644 index 98582e6c..00000000 --- a/win32/wintask.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* -* Descent 3 -* Copyright (C) 2024 Parallax Software -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . - ---- HISTORICAL COMMENTS FOLLOW --- - - * $Logfile: /DescentIII/Main/win32/wintask.cpp $ - * $Revision: 5 $ - * $Date: 9/14/98 4:02p $ - * $Author: Samir $ - * - * Task manager - * - * $Log: /DescentIII/Main/win32/wintask.cpp $ - * - * 5 9/14/98 4:02p Samir - * allow variable lengths of blocking for tasks. - * - * 4 8/10/98 5:54p Samir - * added mutexes. - * - * 3 10/22/97 10:57a Samir - * Made highest priority time critical again. - * - * 2 10/17/97 11:37a Samir - * Changed highest task priority from TIME_CRITICAL to HIGHEST. - * - * 2 6/09/97 4:17p Samir - * RCS check in. - * - * $NoKeywords: $ - */ - -// Library includes -#include "TaskSystem.h" -#include "pserror.h" - -// Standard includes -#include - -// --------------------------------------------------------------------------- -// osTask implementation -// --------------------------------------------------------------------------- - -osTask::osTask(unsigned (*func)(void *), tTaskPriority priority, void *parm) { - int pri; - - task_os_handle = nullptr; - - task_os_handle = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)func, (LPVOID)parm, 0, nullptr); - if (task_os_handle == nullptr) { - Int3(); // Get Samir. - } - - if (priority == TASKPRIORITY_HIGHEST) - pri = THREAD_PRIORITY_TIME_CRITICAL; - else if (priority == TASKPRIORITY_NORMAL) - pri = THREAD_PRIORITY_NORMAL; - else if (priority == TASKPRIORITY_LOWEST) - pri = THREAD_PRIORITY_LOWEST; - - SetThreadPriority((HANDLE)task_os_handle, pri); -} - -osTask::~osTask() { - if (task_os_handle) { - CloseHandle((HANDLE)task_os_handle); - } -} - -bool osTask::error() const { - if (!task_os_handle) - return 1; - else - return 0; -} - -void osTask::suspend() // suspends task -{ - if (task_os_handle) { - SuspendThread((HANDLE)task_os_handle); - } -} - -void osTask::resume() // resumes task -{ - if (task_os_handle) { - ResumeThread((HANDLE)task_os_handle); - } -} - -// --------------------------------------------------------------------------- -// osEvent implementation -// --------------------------------------------------------------------------- -osEvent::osEvent(char *name) { event_os_handle = CreateEvent(NULL, TRUE, FALSE, name); } - -osEvent::~osEvent() { - if (event_os_handle) - CloseHandle((HANDLE)event_os_handle); -} - -// signal the event so blocking can stop -void osEvent::signal() { - if (event_os_handle) - SetEvent((HANDLE)event_os_handle); -} - -// clear the event so blocking can continue -void osEvent::clear() { - if (event_os_handle) - ResetEvent((HANDLE)event_os_handle); -} - -// block until signaled -bool osEvent::block(int timeout) { - if (event_os_handle) { - DWORD res = WaitForSingleObject((HANDLE)event_os_handle, (timeout == -1) ? INFINITE : timeout); - if (res == WAIT_OBJECT_0) - return 1; - else if (res == WAIT_ABANDONED) - return 0; - } - - return 0; -} - -bool osEvent::error() const { - if (!event_os_handle) - return 1; - else - return 0; -}