SignalDrivenThread.h revision 13d8c7b4650fb7897b4291ed9b3d57b19f7d1ccd
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 62private: 63 status_t readyToRun(); 64 virtual status_t readyToRunInternal() = 0; 65 66 bool threadLoop(); 67 virtual void threadFunctionInternal() = 0; 68 69 void ClearSignal(); 70 71 uint32_t m_receivedSignal; 72 uint32_t m_processingSignal; 73 74 Mutex m_signalMutex; 75 Condition m_threadCondition; 76}; 77 78}; // namespace android 79 80#endif 81