1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_THREAD_HXX 25 #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_THREAD_HXX 26 27 #include "sal/config.h" 28 29 #include <cstddef> 30 #include <new> 31 #include "osl/thread.hxx" 32 #include "sal/types.h" 33 #include "salhelper/simplereferenceobject.hxx" 34 35 /// @HTML 36 37 namespace dp_gui { 38 39 /** 40 A safe encapsulation of <code>osl::Thread</code>. 41 */ 42 class Thread: public salhelper::SimpleReferenceObject, private osl::Thread { 43 public: 44 Thread(); 45 46 /** 47 Launch the thread. 48 49 <p>This function must be called at most once.</p> 50 */ 51 void launch(); 52 53 using osl::Thread::join; 54 55 static void * operator new(std::size_t size) throw (std::bad_alloc); 56 57 static void operator delete(void * p) throw (); 58 59 protected: 60 virtual ~Thread(); 61 62 /** 63 The main function executed by the thread. 64 65 <p>Any exceptions terminate the thread and are effectively ignored.</p> 66 */ 67 virtual void execute() = 0; 68 69 private: 70 Thread(Thread &); // not defined 71 void operator =(Thread &); // not defined 72 73 virtual void SAL_CALL run(); 74 75 virtual void SAL_CALL onTerminated(); 76 }; 77 78 } 79 80 #endif 81