Contents Up Previous Next

wxTime

Representation of time and date.

NOTE: this class is retained only for compatibility, and has been replaced by wxDateTime. wxTime may be withdrawn in future versions of wxWidgets.

Derived from

wxObject

Include files

<wx/time.h>

Data structures

typedef unsigned short hourTy;
typedef unsigned short minuteTy;
typedef unsigned short secondTy;
typedef unsigned long clockTy;
enum tFormat { wx12h, wx24h };
enum tPrecision { wxStdMinSec, wxStdMin };
See also

wxDate

Members

wxTime::wxTime
wxTime::GetDay
wxTime::GetDayOfWeek
wxTime::GetHour
wxTime::GetHourGMT
wxTime::GetMinute
wxTime::GetMinuteGMT
wxTime::GetMonth
wxTime::GetSecond
wxTime::GetSecondGMT
wxTime::GetSeconds
wxTime::GetYear
wxTime::FormatTime
wxTime::IsBetween
wxTime::Max
wxTime::Min
wxTime::SetFormatxtimesetformat">wxTime::SeFACE="Arial, Lucida, Helvetica"> Create a detached thread.
wxTHREAD_JOINABLE Create a joinable thread


wxThread::~wxThread

~wxThread()

The destructor frees the resources associated with the thread. Notice that you should never delete a detached thread - you may only call Delete on it or wait until it terminates (and auto destructs) itself. Because the detached threads delete themselves, they can only be allocated on the heap.

Joinable threads should be deleted explicitly. The Delete and Kill functions will not delete the C++ thread object. It is also safe to allocate them on stack.


wxThread::Create

wxThreadError Create(unsigned int stackSize = 0)

Creates a new thread. The thread object is created in the suspended state, and you should call Run to start running it. You may optionally specify the stack size to be allocated to it (Ignored on platforms that don't support setting it explicitly, eg. Unix).

Return value

One of:

wxTHREAD_NO_ERROR There was no error.
wxTHREAD_NO_RESOURCE There were insufficient resources to create a new thread.
wxTHREAD_RUNNING The thread is already running.


wxThread::Delete

void Delete()

Calling Delete is a graceful way to terminate the thread. It asks the thread to terminate and, if the thread code is well written, the thread will terminate after the next call to TestDestroy which should happen quite soon.

However, if the thread doesn't call TestDestroy often enough (or at all), the function will not return immediately, but wait until the thread terminates. As it may take a long time, and the message processing is not stopped during this function execution, message handlers may be called from inside it!

Delete() may be called for thread in any state: running, paused or even not yet created. Moreover, it must be called if Create or Run failed for a detached thread to free the memory occupied by the thread object. This cleanup will be done in the destructor for joinable threads.

Delete() may be called for a thread in any state: running, paused or even not yet created. Moreover, it must be called if Create or Run fail to free the memory occupied by the thread object. However, you should not call Delete() on a detached thread which already terminated - doing so will probably result in a crash because the thread object doesn't exist any more.

For detached threads Delete() will also delete the C++ thread object, but it will not do this for joinable ones.

This function can only be called from another thread context.


wxThread::Entry

virtual ExitCode Entry()

This is the entry point of the thread. This function is pure virtual and must be implemented by any derived class. The thread execution will start here.

The returned value is the thread exit code which is only useful for joinable threads and is the value returned by Wait.

This function is called by wxWidgets itself and should never be called directly.


wxThread::Exit

void Exit(ExitCode exitcode = 0)

This is a protected function of the wxThread class and thus can only be called from a derived class. It also can only be called in the context of this thread, i.e. a thread can only exit from itself, not from another thread.

This function will terminate the OS thread (i.e. stop the associated path of execution) and also delete the associated C++ object for detached threads. wxThread::OnExit will be called just before exiting.


wxThread::GetCPUCount

static int GetCPUCount()

Returns the number of system CPUs or -1 if the value is unknown.

See also

SetConcurrency


wxThread::GetCurrentId

static unsigned long GetCurrentId()

Returns the platform specific thread ID of the current thread as a long. This can be used to uniquely identify threads, even if they are not wxThreads.


wxThread::GetId

unsigned long GetId() const

Gets the thread identifier: this is a platform dependent number that uniquely identifies the thread throughout the system during its existence (i.e. the thread identifiers may be reused).


wxThread::GetPriority

int GetPriority() const

Gets the priority of the thread, between zero and 100.

The following priorities are defined:

WXTHREAD_MIN_PRIORITY 0
WXTHREAD_DEFAULT_PRIORITY 50
WXTHREAD_MAX_PRIORITY