OEThread¶
class OEThread
Abstracts away the notion of an operating system thread in a
cross-platform way. Users can subclass this class and implement the
OEThread.Run
method in order to create new
operating system threads running any arbitrary code.
GetArg¶
void *GetArg()
Used by the implementation to pass the void *
argument from
OEThread.Start
to the
OEThread.Run
method in a new thread. Not
guaranteed to return anything useful on all platforms, and may
go away in a future version.
GetReturn¶
void *GetReturn()
Used by the implementation to pass the void *
returned from
OEThread.Run
to the
OEThread.Join
method in a new thread. Not
guaranteed to return anything useful on all platforms, and may
go away in a future version. If the thread is still running,
this method can data race with the running thread, this should
only be called after this thread is joined.
GetStackSize¶
unsigned int GetStackSize() const
Return the stack size chosen for this thread by a previous call
to OEThread.SetStackSize
. By default,
this method will return 0
, specifying that the operating
system’s default stack size will be used.
Join¶
void *Join()
Blocks and wait for the thread to finish, returning the void *
returned by the overloaded OEThread.Run
method.
Run¶
void *Run(void *targ)=0
Pure virtual method expected to be overloaded by the inheriting
class. This method will be started in a separate operating
system thread after a successful call to
OEThread.Start
.
SetArg¶
void SetArg(void *targ)
Used by the implementation to pass the void *
argument from
OEThread.Start
to the
OEThread.Run
method in a new thread. Not
guaranteed to return anything useful on all platforms, and may
go away in a future version.
SetReturn¶
void SetReturn(void *targ)
Used by the implementation to pass the void *
returned from
OEThread.Run
to the
OEThread.Join
method in a new thread. Not
guaranteed to return anything useful on all platforms, and may
go away in a future version.
SetStackSize¶
void SetStackSize(unsigned int stackSize)
Specify the maximum size a stack can grow for this newly created
operating system thread. This method must be called before
calling OEThread.Start
. Depending on the
platform and the operating system settings,
OEThread.Start
may fail and return
false
if the value is considered inappropriate by the
operating system. The value of 0
specifies to just use the
operating system default.
Start¶
bool Start(void *targ=0)
Returns true
if the operating system thread is successfully
created, false
otherwise.