home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
progjorn
/
pj_7_2.arc
/
TASK.HXX
< prev
next >
Wrap
Text File
|
1988-12-21
|
1KB
|
60 lines
// task.hxx
//
// implements the Task class. this manages the spawning of an OS/2 thread.
//
// author: vaughn vernon
// (c) Copyright 1988 Aspen Scientific
// All Rights Reserved.
#ifndef __TASKCLASS__
# define __TASKCLASS__
# ifndef APIENTRY
# include <os2def.h>
# endif
# ifndef INCL_DOS
# define INCL_DOS
# include <bsedos.h>
# endif
// the Task class
class Task {
USHORT returnCode;
public:
// constructor, it spawns the thread
Task( VOID auto (FAR * routine)(), USHORT stackSize ) {
PBYTE stack; // the stack pointer
TID taskID; // the thread/task ID
stack = (PBYTE) new BYTE[ stackSize ];
if ( stack != PBYTE(0) ) {
// the stack grows down
stack += stackSize;
// spawn thread
returnCode = DosCreateThread( routine,
(PTID) &taskID, (PBYTE) stack );
}
else
returnCode = TRUE; // in this case bad
}
// the destructor does nothing
// the stack is freed by OS/2 when the Task completes.
~Task() { ; }
// methods
// was the thread executed?
BOOL GetStatus() {
return returnCode ? FALSE:TRUE;
}
};
#endif