//
//  DDTimerObject.h
//  DDToolsKit_Private
//  Created by DDIsFriend on 2022/7/29.

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, DDTimerRunState) {
    DDTimerRunStateNotActivate,
    DDTimerRunStateActivate,
    DDTimerRunStateSuspend,
};

@interface DDTimerObject : NSObject
@property (nonatomic, copy, readonly)NSString *name;
@property (nonatomic, assign, readonly)NSTimeInterval timeInterval;
@property (nonatomic, assign, readonly)BOOL isActivate;
@property (nonatomic, assign, readonly)DDTimerRunState runState;
/**
 *return a timerObject with dispatch_source_t.
 *@param name timer's name is required.
 *@param timerInterval The nanosecond interval for the timer.
 *@param repeatCount if repeatCount is 0, the timer will cycle always.
 *@param timerBlock what to do in this timer.
 */
+ (DDTimerObject *)dd_timerObjectWithName:(NSString *)name timeInterval:(NSTimeInterval)timerInterval repeatCount:(NSInteger)repeatCount timerBlock:(nullable void(^)(DDTimerObject *_Nullable timerObject))timerBlock completionHandler:(nullable void(^)(DDTimerObject *_Nullable timerObject))completionHandler;

/**
 * the timerObject is whether activate now.
 */
- (DDTimerRunState)dd_timerRunState;

/**
 * activate timer that timer can run.
 */
- (void)dd_activateTimerObject;
/**
 * cancel dispatch_source_t.
 */
- (void)dd_cancelTimerObject;

/**
 * suspend timer.
 */
- (void)dd_suspendTimerObject;

/**
 * resume timer.
 */
- (void)dd_resumeTimerObject;
@end

NS_ASSUME_NONNULL_END
