This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copyright (c) 2011-2013 Ole Petter Bang <[email protected]> | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
'Software'), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <ReactiveCocoa/ReactiveCocoa.h> | |
@interface Test : NSObject | |
@property (nonatomic, strong) Test *object; | |
@property (nonatomic) NSUInteger primitive; | |
@end | |
@implementation Test | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <ReactiveCocoa/ReactiveCocoa.h> | |
@interface CountUpToXEnumerator : NSEnumerator | |
+ (instancetype)countUpTo:(NSUInteger)x; | |
@end | |
@implementation CountUpToXEnumerator { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <pthread.h> | |
#import <mach/thread_act.h> | |
// These two functions are declared in mach/thread_policy.h, but are commented out. | |
// They are documented here: https://developer.apple.com/library/mac/#releasenotes/Performance/RN-AffinityAPI/_index.html | |
kern_return_t thread_policy_set( | |
thread_t thread, | |
thread_policy_flavor_t flavor, | |
thread_policy_t policy_info, | |
mach_msg_type_number_t count); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The x86 cpuid instruction gives information about the processor | |
static inline void cpuid(uint32_t code, uint32_t data[4]) { | |
asm volatile("cpuid":"=a"(*data),"=b"(*(data+1)), | |
"=c"(*(data+2)),"=d"(*(data+3)):"a"(code)); | |
} | |
// Gets the APIC ID of the processor. Returns a unique identifier for each core. | |
static inline uint8_t apic_id(void) { | |
uint32_t data[4]; | |
cpuid(1, data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(id<RACSignal> signal in signals) { | |
RACDisposable *disposable = [signal subscribe:[RACSubscriber subscriberWithNext:^(id x) { | |
@synchronized(lastValues) { | |
[lastValues setObject:x ? : [RACTupleNil tupleNil] forKey:[NSString stringWithFormat:@"%p", signal]]; | |
if(lastValues.count == signals.count) { | |
NSMutableArray *orderedValues = [NSMutableArray arrayWithCapacity:signals.count]; | |
for(id<RACSignal> o in signals) { | |
[orderedValues addObject:[lastValues objectForKey:[NSString stringWithFormat:@"%p", o]]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe(@"-repeat", ^{ | |
__block id<RACSubscribable> subscribable = nil; | |
beforeEach(^{ | |
subscribable = [RACSubscribable createSubscribable:^RACDisposable *(id<RACSubscriber> subscriber) { | |
[subscriber sendNext:nil]; | |
[subscriber sendCompleted]; | |
return nil; | |
}]; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (instancetype)initWithURL:(NSURL *)url type:(NSString *)type { | |
self = [super initWithURL:url type:type]; | |
if (!self) { | |
return nil; | |
} | |
_contentBacking = [RACReplaySubject replaySubjectWithCapacity:1]; | |
NSError *error; | |
NSString *content = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; | |
if (!error) { | |
[_contentBacking sendNext:content]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
name: "almond", | |
out: "main-built.js", | |
include: ["main"], | |
insertRequire: ["main"], | |
wrap: true, // This is the crucial option | |
mainConfigFile: "main.js", | |
optimize: "none" | |
}) |