mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Remove unused osTask class
This commit is contained in:
parent
fc209ddba4
commit
cb9e0f8828
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
--- 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
|
@ -45,7 +45,6 @@
|
||||
#include <cctype>
|
||||
|
||||
#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
|
||||
|
@ -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);
|
||||
|
@ -3,7 +3,6 @@ set(CPPS
|
||||
wincon.cpp
|
||||
WinController.cpp
|
||||
windata.cpp
|
||||
wintask.cpp
|
||||
)
|
||||
|
||||
add_library(win32 STATIC ${CPPS})
|
||||
|
@ -64,18 +64,14 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <windows.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "AppConsole.h"
|
||||
#include "TaskSystem.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <process.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#define CON_SCROLL_ROWS 25
|
||||
#define CON_SCROLL_COLS 80
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
--- 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 <windows.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user