class Thread

Thread support class. More...

Full nameTelEngine::Thread
Definition#include <yateclass.h>
InheritsTelEngine::Runnable [public ]
Inherited byClient, Router
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Static Methods

Protected Methods


Detailed Description

A thread is a separate execution context that exists in the same address space. Threads make better use of multiple processor machines and allow blocking one execution thread while allowing other to run.

enum Priority { Lowest, Low, Normal, High, Highest }

Priority

Running priorities, their mapping is operating system dependent

void  cleanup ()

cleanup

[virtual]

This method is called when the current thread terminates.

bool  startup ()

startup

Actually starts running the new thread which lingers after creation

Returns: False if an error occured, true if started ok

bool  error ()

error

[const]

Check if the thread creation failed

Returns: True if an error occured, false if created ok

bool  running ()

running

[const]

Check if the thread is running or not

Returns: True if running, false if it has terminated or no startup called

inline int  locks ()

locks

[const]

Count how many Yate mutexes are kept locked by this thread

Returns: Number of Mutex locks held by this thread

inline bool  locked ()

locked

[const]

Check if the thread is currently helding or attempting to lock a mutex

Returns: True if the current thread is in an unsafe to cancel state

const char*  name ()

name

[const]

Get the name of this thread

Returns: The pointer that was passed in the constructor

const char*  currentName ()

currentName

[static]

Get the name of the currently running thread

Returns: The pointer that was passed in the thread's constructor

void  yield (bool exitCheck = false)

yield

[static]

Give up the currently running timeslice. Note that on some platforms it also sleeps for the operating system's scheduler resolution

Parameters:
exitCheckTerminate the thread if asked so

void  sleep (unsigned int sec, bool exitCheck = false)

sleep

[static]

Sleep for a number of seconds

Parameters:
secNumber of seconds to sleep
exitCheckTerminate the thread if asked so

void  msleep (unsigned long msec, bool exitCheck = false)

msleep

[static]

Sleep for a number of milliseconds

Parameters:
msecNumber of milliseconds to sleep
exitCheckTerminate the thread if asked so

void  usleep (unsigned long usec, bool exitCheck = false)

usleep

[static]

Sleep for a number of microseconds

Parameters:
usecNumber of microseconds to sleep, may be rounded to milliseconds on some platforms
exitCheckTerminate the thread if asked so

Thread*  current ()

current

[static]

Get a pointer to the currently running thread

Returns: A pointer to the current thread or NULL for the main thread or threads created by other libraries

int  count ()

count

[static]

Get the number of Yate created threads

Returns: Count of current Thread objects

bool  check (bool exitNow = true)

check

[static]

Check if the current thread was asked to terminate.

Parameters:
exitNowIf thread is marked as cancelled then terminate immediately

Returns: False if thread should continue running, true if it should stop

void  exit ()

exit

[static]

Terminates the current thread.

void  cancel (bool hard = false)

cancel

Terminates the specified thread.

Parameters:
hardKill the thread the hard way rather than just setting an exit check marker

inline bool  isCurrent ()

isCurrent

[const]

Check if this thread is the currently running thread

Returns: True if this is the current thread

Priority  priority (const char* name, Priority defvalue = Normal)

priority

[static]

Convert a priority name to a thread priority level

Parameters:
nameName of the requested level
defvaluePriority to return in case of an invalid name

Returns: A thread priority level

const char*  priority (Priority prio)

priority

[static]

Convert a priority level to a textual name

Parameters:
prioPriority level to convert

Returns: Name of the level or NULL if an invalid argument was provided

void  killall ()

killall

[static]

Kills all other running threads. Ouch! Must be called from the main thread or it does nothing.

void  preExec ()

preExec

[static]

On some platforms this method kills all other running threads. Must be called after fork() but before any exec*() call.

 Thread (const char *name = 0, Priority prio = Normal)

Thread

[protected]

Creates and starts a new thread

Parameters:
nameStatic name of the thread (for debugging purpose only)
prioThread priority

 Thread (const char *name, const char* prio)

Thread

[protected]

Creates and starts a new thread

Parameters:
nameStatic name of the thread (for debugging purpose only)
prioThread priority level name

 ~Thread ()

~Thread

[protected virtual]

The destructor is called when the thread terminates


Generated by: root on dragoshel on Sat Apr 14 01:50:50 2007, using kdoc 2.0a54.