Thread.hpp
#if !defined(__THREAD_HPP)
#define __THREAD_HPP
/*
CoreLinux++
Copyright (C) 1999,2000 CoreLinux Consortium
The CoreLinux++ Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The CoreLinux++ Library Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#if !defined IN_COMMON_HPP
#error Thread.hpp is included by Common.hpp only.
#endif
#if !defined(__SINGLETON_HPP)
#include <Singleton.hpp>
#endif
#if !defined(__MAP_HPP)
#include <Map.hpp>
#endif
#if !defined(__INVALIDTHREADEXCEPTION_HPP)
#include <InvalidThreadException.hpp>
#endif
namespace corelinux
{
DECLARE_CLASS( ThreadContext );
CORELINUX_MAP
(
ThreadIdentifier,
ThreadContextPtr,
std::less<ThreadIdentifier>,
ThreadMap
);
//
// Start of class declaration
//
DECLARE_CLASS( Thread );
DECLARE_TYPE( Singleton<Thread>, ThreadManager );
class Thread : public Synchronized
{
public:
//
// Constructors and destructor
//
Thread( void ) throw( Assertion );
virtual ~Thread( void );
//
// Operator overloads
//
//
// Accessors (class)
//
static Int getKernelError( void );
static ThreadIdentifier getThreadIdentifier( void );
static ThreadIdentifier getParentThreadIdentifier( void );
static ThreadIdentifierCref getThreadManagerIdentifier( void );
static ThreadContextCref getThreadContext( ThreadIdentifierCref )
throw ( InvalidThreadException ) ;
static Count getCreatedThreadCount( void );
static Count getActiveThreadCount( void );
static Count getBlockedThreadCount( void );
static Count getCompletedThreadCount( void );
static void dump( void );
//
// Mutators
//
static ThreadIdentifier startThread( ThreadContextRef ) ;
static Int waitForThread( ThreadIdentifierCref )
throw ( InvalidThreadException );
static void destroyThreadContext( ThreadIdentifierCref )
throw ( InvalidThreadException, Assertion );
static Int getThreadPriority( ThreadIdentifierCref )
throw ( InvalidThreadException, Assertion );
static void setThreadPriority( ThreadIdentifierCref, Int )
throw ( InvalidThreadException, Assertion );
protected:
//
// Constructor
//
Thread( ThreadCref ) throw ( Assertion );
//
// Operator overloads
//
ThreadRef operator=( ThreadCref ) throw ( Assertion );
bool operator==( ThreadCref ) const throw ( Assertion ) ;
//
// Thread terminate
//
static void threadTerminated( Int, VoidPtr, VoidPtr );
protected:
static ThreadManager theThreadManager;
private:
static ThreadMap theThreadMap;
static ThreadIdentifier theThreadManagerId;
static Count theThreadCount;
};
}
#endif // if !defined(__THREAD_HPP)
/*
Common rcs information do not modify
$Author: dulimart $
$Revision: 1.5 $
$Date: 2001/03/20 04:06:50 $
$Locker: $
*/
corelinux::Thread::startThread
static ThreadIdentifier startThread(ThreadContextRef)
Start a thread as described by the context.
Definition: Thread.cpp:302
corelinux::Thread::~Thread
virtual ~Thread(void)
Virtual destructor.
Definition: Thread.cpp:101
corelinux::Thread::getThreadContext
static ThreadContextCref getThreadContext(ThreadIdentifierCref)
Retrieve a ThreadContext given a identifier.
Definition: Thread.cpp:152
corelinux::Thread::getThreadManagerIdentifier
static ThreadIdentifierCref getThreadManagerIdentifier(void)
getThreadManagerIdentifier retrieves the thread that Thread was instantiated from ...
Definition: Thread.cpp:145
corelinux::Thread::getCompletedThreadCount
static Count getCompletedThreadCount(void)
Retrieve the number of threads that are not starting or running or waiting to run.
Definition: Thread.cpp:215
corelinux::Thread::getCreatedThreadCount
static Count getCreatedThreadCount(void)
Retrieve the number of created threads.
Definition: Thread.cpp:171
corelinux::Thread::theThreadManager
static ThreadManager theThreadManager
The singleton instance of Thread for synchronization.
Definition: Thread.hpp:285
corelinux::ThreadContext
ThreadContext describes the context in which the thread operates.
Definition: ThreadContext.hpp:137
corelinux::Thread::dump
static void dump(void)
Debugging method for the moment.
Definition: Thread.cpp:283
corelinux::Thread::waitForThread
static Int waitForThread(ThreadIdentifierCref)
Blocks the caller until the thread has ended execution, retrieving the return code from the associate...
Definition: Thread.cpp:375
corelinux::InvalidThreadException
InvalidThreadException describes an exception that is thrown when a operation is attempted on a non-m...
Definition: InvalidThreadException.hpp:43
corelinux::Thread::operator=
ThreadRef operator=(ThreadCref)
Assignment operator won&#39;t do, we should never get here anyway but the compiler will generate the miss...
Definition: Thread.cpp:108
corelinux::Singleton
Ensure a class only has one instance, and provide a global point of access to it. ...
Definition: Singleton.hpp:38
corelinux::Thread::getBlockedThreadCount
static Count getBlockedThreadCount(void)
Retrieve the number of threads that are waiting ro tun.
Definition: Thread.cpp:249
corelinux::Thread::getThreadIdentifier
static ThreadIdentifier getThreadIdentifier(void)
getThreadIdentifier retrieves the kernel process id for the caller thread
Definition: Thread.cpp:131
corelinux::Thread::getKernelError
static Int getKernelError(void)
getKernelError returns the thread instance errno for the last kernel call the thread made ...
Definition: Thread.cpp:124
corelinux::Thread::Thread
Thread(void)
Default constructor.
Definition: Thread.cpp:58
corelinux::Thread::setThreadPriority
static void setThreadPriority(ThreadIdentifierCref, Int)
Set thread priority for the given indentifier.
Definition: Thread.cpp:438
corelinux::Thread::getParentThreadIdentifier
static ThreadIdentifier getParentThreadIdentifier(void)
getParentThreadIdentifier retrieves the parent thread of the current thread.
Definition: Thread.cpp:138
corelinux::ScalarIdentifier
ScalarIdentifier provides a templated interface for declaring CoreLinux Identifiers for simple scalar...
Definition: ScalarIdentifiers.hpp:37
corelinux::Thread::operator==
bool operator==(ThreadCref) const
Equality operator not valid for class utility.
Definition: Thread.cpp:116
corelinux::Thread::getActiveThreadCount
static Count getActiveThreadCount(void)
Retrieve the number of threads that are starting or running.
Definition: Thread.cpp:178
corelinux::Assertion
Assertion is-a Exception created when an assertion fails.
Definition: Assertion.hpp:423
corelinux::Synchronized
Synchronized is a mixin which allows class objects to enable monitor functionality.
Definition: Synchronized.hpp:41
corelinux::Thread::getThreadPriority
static Int getThreadPriority(ThreadIdentifierCref)
Get thread priority for the given indentifier.
Definition: Thread.cpp:429
corelinux::Thread::destroyThreadContext
static void destroyThreadContext(ThreadIdentifierCref)
Destroys the managed context for the given identifier.
Definition: Thread.cpp:387
corelinux::Thread
Thread is a framework for the creation, management, and destruction of caller threads.
Definition: Thread.hpp:73

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium