SignalDrivenThread.h revision c15a6b003394494149ef7d65ae35c38755cb8b93
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 30 31 32#ifndef SIGNAL_DRIVEN_THREAD_H 33#define SIGNAL_DRIVEN_THREAD_H 34 35#include <utils/threads.h> 36 37namespace android { 38 39#define SIGNAL_THREAD_TERMINATE (1<<0) 40#define SIGNAL_THREAD_PAUSE (1<<1) 41 42#define SIGNAL_THREAD_COMMON_LAST (1<<3) 43 44class SignalDrivenThread : public Thread { 45public: 46 SignalDrivenThread(); 47 SignalDrivenThread(const char* name, 48 int32_t priority, size_t stack); 49 virtual ~SignalDrivenThread(); 50 51 status_t SetSignal(uint32_t signal); 52 53 54 uint32_t GetProcessingSignal(); 55 //void ClearProcessingSignal(uint32_t signal); 56 57 58private: 59 status_t readyToRun(); 60 virtual status_t readyToRunInternal() = 0; 61 62 bool threadLoop(); 63 virtual void threadLoopInternal() = 0; 64 65 void ClearSignal(); 66 67 uint32_t m_receivedSignal; 68 uint32_t m_processingSignal; 69 70 Mutex m_signalMutex; 71 Condition m_threadCondition; 72}; 73 74}; // namespace android 75 76#endif 77 78