UDK 3.2.7 C/C++ API Reference
salhelper/thread.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License or as specified alternatively below. You may obtain a copy of
00008  * the License at http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * Major Contributor(s):
00016  * [ Copyright (C) 2012 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com>
00017  *   (initial developer) ]
00018  *
00019  * All Rights Reserved.
00020  *
00021  * For minor contributions see the git repository.
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
00025  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
00026  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
00027  * instead of those above.
00028  */
00029 
00030 #ifndef INCLUDED_SALHELPER_THREAD_HXX
00031 #define INCLUDED_SALHELPER_THREAD_HXX
00032 
00033 #include "sal/config.h"
00034 
00035 #include <cstddef>
00036 
00037 #include "osl/thread.hxx"
00038 #include "sal/types.h"
00039 #include "salhelper/salhelperdllapi.h"
00040 #include "salhelper/simplereferenceobject.hxx"
00041 
00042 namespace salhelper {
00043 
00049 class SALHELPER_DLLPUBLIC Thread:
00050     public salhelper::SimpleReferenceObject, private osl::Thread
00051 {
00052 public:
00057     Thread(char const * name);
00058 
00069     void launch();
00070 
00071     using osl::Thread::getIdentifier;
00072     using osl::Thread::join;
00073     using osl::Thread::schedule;
00074     using osl::Thread::terminate;
00075 
00076     // While the below static member functions should arguably always be called
00077     // with qualified (osl::Thread) names, compilers would still complain that
00078     // they are inaccessible from within derivations of salhelper::Thread (an
00079     // alternative would be to force such derivations to use global names,
00080     // prefixed with ::osl::Thread):
00081     using osl::Thread::getCurrentIdentifier;
00082     using osl::Thread::wait;
00083     using osl::Thread::yield;
00084 
00085     static inline void * operator new(std::size_t size)
00086     { return SimpleReferenceObject::operator new(size); }
00087 
00088     static inline void operator delete(void * pointer)
00089     { SimpleReferenceObject::operator delete(pointer); }
00090 
00091 protected:
00092     virtual ~Thread();
00093 
00099     virtual void execute() = 0;
00100 
00101 private:
00102     virtual void SAL_CALL run();
00103 
00104     virtual void SAL_CALL onTerminated();
00105 
00106     char const * name_;
00107 };
00108 
00109 }
00110 
00111 #endif
00112 
00113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines