aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/utils/MCOOperation.h
blob: 1c4583e4c2383b4666c5504dc88a1f18def699f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
//  MCOOperation.h
//  mailcore2
//
//  Created by Matt Ronge on 01/31/13.
//  Copyright (c) 2013 __MyCompanyName__. All rights reserved.
//

#ifndef MAILCORE_MCOOPERATION_H

#define MAILCORE_MCOOPERATION_H

#import <Foundation/Foundation.h>

@interface MCOOperation : NSObject

/** Returns whether the operation is cancelled.*/
@property (readonly) BOOL isCancelled;

/** Returns whether the operation should run even if it's cancelled.*/
@property (nonatomic, assign) BOOL shouldRunWhenCancelled;

/** The queue this operation dispatches the callback on.  Defaults to the main queue.
 This property should be used only if there's performance issue creating or calling the callback
 in the main thread. */
#if OS_OBJECT_USE_OBJC
@property (nonatomic, retain) dispatch_queue_t callbackDispatchQueue;
#else
@property (nonatomic, assign) dispatch_queue_t callbackDispatchQueue;
#endif

/** This methods is called on the main thread when the asynchronous operation is finished.
 Needs to be overriden by subclasses.*/
- (void) operationCompleted;

/** Cancel the operation.*/
- (void) cancel;

#pragma mark - Unavailable initializers
/** Do not invoke this directly. */
- (instancetype) init NS_UNAVAILABLE;
/** Do not invoke this directly. */
+ (instancetype) new NS_UNAVAILABLE;

@end

#endif