1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef CHRE_PLATFORM_LINUX_SYSTEM_TIMER_BASE_H_ 18 #define CHRE_PLATFORM_LINUX_SYSTEM_TIMER_BASE_H_ 19 20 #include <signal.h> 21 #include <time.h> 22 23 namespace chre { 24 25 /** 26 * The Linux base class for the SystemTimer. The Linux implementation uses a 27 * POSIX timer. 28 */ 29 class SystemTimerBase { 30 protected: 31 //! The timer id that is generated during the initialization phase. 32 timer_t mTimerId; 33 34 //! Tracks whether the timer has been initialized correctly. 35 bool mInitialized = false; 36 37 //! A static method that is invoked by the underlying POSIX timer. 38 static void systemTimerNotifyCallback(union sigval cookie); 39 40 //! A utility function to set a POSIX timer. 41 bool setInternal(uint64_t delayNs); 42 }; 43 44 } // namespace chre 45 46 #endif // CHRE_PLATFORM_LINUX_SYSTEM_TIMER_BASE_H_ 47