<commit_before>## IGFuture

Futures pattern in Objective-C.

### Why?

Inspired by [futuristic](https://github.com/seanlilmateus/futuristic), I want to see if it is possible to be done in Objective-C. Turns out it has been done previously (a.k.a. [MAFuture](https://github.com/mikeash/MAFuture)),
but why not reinvent it?

This is highly experimental, so use it at your own risk!

### Example

```objective-c
NSDate* now = [NSDate date];
NSDate* later = (NSDate*) [[IGFuture alloc] initWithBlock:^id{
    // something CPU intensive!
    [NSThread sleepForTimeInterval:1];

    // return the value
    return [NSDate date];
}];

expect([later timeIntervalSinceDate:now]).to.beCloseToWithin(1, 0.01);
```

1. The future block run immediately in background. When it is needed (at ```[later timeIntervalSinceDate:now]```) and the result is available, it returns immediately. If it is still running, it block and wait for completion. 

2. If you want the future only calculate the results when it is needed, use ```-initWithLazyBlock:```.

3. Note "later" which is a IGFuture object can be used as a NSDate (the returned value of the block).


### Copyright

Copyright (c) 2013 <NAME>. This software is licensed under the MIT License. See LICENSE for details.<commit_msg>Update to README<commit_after>## IGFuture

Futures pattern in Objective-C.

### Why?

Inspired by [futuristic](https://github.com/seanlilmateus/futuristic), I want to see if it is possible to be done in Objective-C. Turns out it has been done previously (a.k.a. [MAFuture](https://github.com/mikeash/MAFuture)),
but why not reinvent it?

This is highly experimental, so use it at your own risk!

### Example

```objective-c
NSDate* now = [NSDate date];
NSDate* later = (NSDate*) [[IGFuture alloc] initWithBlock:^id{
    // something CPU intensive!
    [NSThread sleepForTimeInterval:1];

    // return the value
    return [NSDate date];
}];

expect([later timeIntervalSinceDate:now]).to.beCloseToWithin(1, 0.01);
```

1. The future block run immediately in background. When it is needed (at ```[later timeIntervalSinceDate:now]```) and the result is available, it returns immediately. If it is still running, it block and wait for completion. 

2. If you want the future only calculate the results when it is needed, use ```-initWithLazyBlock:```.

3. Note "later" which is a IGFuture object can be used as a NSDate (the returned value of the block).

### Usage

In your ```Podfile```

```
pod 'IGFuture', :podspec => 'https://raw.github.com/siuying/IGFuture/master/IGFuture.podspec'
```


### Copyright

Copyright (c) 2013 <NAME>. This software is licensed under the MIT License. See LICENSE for details.
{'fraction_non_alphanumeric': 0.11714071856287425, 'fraction_numerical': 0.008982035928143712, 'mean_word_length': 4.335329341317365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '34303', 'n_tokens_mistral': 850, 'n_tokens_neox': 812, 'n_words': 331}