2020-11-29 11:57:47 +00:00
|
|
|
#ifndef INCLUDED_GSTIMEOUTSOURCE_H
|
|
|
|
#define INCLUDED_GSTIMEOUTSOURCE_H
|
|
|
|
|
|
|
|
#import "common.h"
|
|
|
|
#import "GSDispatch.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A helper class that wraps a libdispatch timer.
|
|
|
|
*
|
|
|
|
* Used to implement the timeout of `GSMultiHandle` and `GSEasyHandle`
|
|
|
|
*/
|
|
|
|
@interface GSTimeoutSource : NSObject
|
|
|
|
{
|
2023-01-16 11:13:54 +00:00
|
|
|
dispatch_source_t _timer;
|
|
|
|
NSInteger _timeoutMs;
|
|
|
|
bool _isSuspended;
|
2020-11-29 11:57:47 +00:00
|
|
|
}
|
|
|
|
|
2023-01-13 11:48:22 +00:00
|
|
|
|
2023-01-16 11:13:54 +00:00
|
|
|
- (instancetype) initWithQueue: (dispatch_queue_t)queue
|
|
|
|
handler: (dispatch_block_t)handler;
|
2020-11-29 11:57:47 +00:00
|
|
|
|
2023-01-16 11:13:54 +00:00
|
|
|
- (NSInteger) timeout;
|
|
|
|
- (void) setTimeout: (NSInteger)timeoutMs;
|
2020-11-29 11:57:47 +00:00
|
|
|
|
2023-01-16 11:13:54 +00:00
|
|
|
- (void) suspend;
|
2020-11-29 11:57:47 +00:00
|
|
|
|
2023-01-16 11:13:54 +00:00
|
|
|
- (void) cancel;
|
2020-11-29 11:57:47 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
#endif
|