SignalDrivenThread.h revision 9dd63e1fc352306d6680c517b7ce9936683c78c4
1/* 2** 3** Copyright 2008, The Android Open Source Project 4** Copyright 2012, Samsung Electronics Co. LTD 5** 6** Licensed under the Apache License, Version 2.0 (the "License"); 7** you may not use this file except in compliance with the License. 8** You may obtain a copy of the License at 9** 10** http://www.apache.org/licenses/LICENSE-2.0 11** 12** Unless required by applicable law or agreed to in writing, software 13** distributed under the License is distributed on an "AS IS" BASIS, 14** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15** See the License for the specific language governing permissions and 16** limitations under the License. 17*/ 18 19/*! 20 * \file SignalDrivenThread.h 21 * \brief header file for general thread ( for camera hal2 implementation ) 22 * \author Sungjoong Kang(sj3.kang@samsung.com) 23 * \date 2012/05/31 24 * 25 * <b>Revision History: </b> 26 * - 2012/05/31 : Sungjoong Kang(sj3.kang@samsung.com) \n 27 * Initial Release 28 * 29 * - 2012/07/10 : Sungjoong Kang(sj3.kang@samsung.com) \n 30 * 2nd Release 31 * 32 */ 33 34 35 36#ifndef SIGNAL_DRIVEN_THREAD_H 37#define SIGNAL_DRIVEN_THREAD_H 38 39#include <utils/threads.h> 40 41namespace android { 42 43#define SIGNAL_THREAD_TERMINATE (1<<0) 44#define SIGNAL_THREAD_PAUSE (1<<1) 45 46#define SIGNAL_THREAD_COMMON_LAST (1<<3) 47 48class SignalDrivenThread:public Thread { 49public: 50 SignalDrivenThread(); 51 SignalDrivenThread(const char *name, 52 int32_t priority, size_t stack); 53 virtual ~SignalDrivenThread(); 54 55 status_t SetSignal(uint32_t signal); 56 57 uint32_t GetProcessingSignal(); 58 //void ClearProcessingSignal(uint32_t signal); 59 void Start(const char *name, 60 int32_t priority, size_t stack); 61 bool IsTerminated(); 62 63private: 64 status_t readyToRun(); 65 virtual status_t readyToRunInternal() = 0; 66 67 bool threadLoop(); 68 virtual void threadFunctionInternal() = 0; 69 70 void ClearSignal(); 71 72 uint32_t m_receivedSignal; 73 uint32_t m_processingSignal; 74 75 Mutex m_signalMutex; 76 Condition m_threadCondition; 77 bool m_isTerminated; 78}; 79 80}; // namespace android 81 82#endif 83