Skip to content

Commit b604227

Browse files
committed
After a code review since last BookMacster shipment
1 parent 7fa2c1a commit b604227

7 files changed

+57
-19
lines changed

SSYBlocker.h

+22-16
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,52 @@
22

33

44
/*!
5-
@brief This class exposes three methods to block a "manager" thread
5+
@brief This class exposes three methods to block a "waiter" thread
66
until a "worker" thread completes work.
7+
8+
@details The typical usage of an SSYBlocker is:
9+
10+
• Waiter or Worker sends +alloc -init.
11+
• Worker sends -lockLock.
12+
• Worker begins work.
13+
• Waiter sends -blockForLock, which blocks.
14+
• Worker completes work.
15+
• Worker sends -unlockLock
16+
• -blockForLock returns, and Waiter continues its execution
17+
18+
Memory management of an SSYBlocker instance can be dangerous
19+
if you cannot guarantee the order in which the messages will
20+
be sent, or edge cases in which they might be re-sent. If you
21+
don't have too many of these things, you might want to be
22+
conservative and retain them as instance variables of some
23+
long-lived object.
724
*/
825
@interface SSYBlocker : NSObject {
926
NSConditionLock* m_lock ;
1027
}
1128

1229
/*!
1330
@brief Initializes the receiver and its condition lock.
14-
15-
@details This method should be invoked on the "manager" thread.
1631
*/
1732
- (id)init ;
1833

1934
/*!
2035
@brief Locks the receiver's condition lock.
21-
22-
@details This method should be invoked on the "worker" thread before
23-
beginning the work.
2436
*/
2537
- (void)lockLock ;
2638

2739
/*!
2840
@brief Blocks until the receiver's condition lock is unlocked
29-
by -unlockLock, and then, before returning, removes the condition
30-
lock from the receiver's info dictionary.
31-
32-
@details This method should be invoked on the "manager" thread after
33-
spinning off the "worker" thread to do the work.
41+
by -unlockLock.
3442
*/
3543
- (void)blockForLock ;
3644

3745
/*!
3846
@brief Unlocks the receiver's condition lock.
3947
40-
@details This method should be invoked on the "worker" thread after work
41-
has been completed. Before unlocking the lock, it checks to
42-
see that it is still locked, so it is OK if, during some error
43-
condition, you send -prepareLock, -lockLock, and then send
44-
this message more than once.
48+
@details Before unlocking the lock, this method checks to see that the
49+
receiver's lock is still locked, so it is OK if, during some edge case
50+
condition, you send this message more than once.
4551
*/
4652
- (void)unlockLock ;
4753

SSYLazyView.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#import "SSYLazyView.h"
2-
#import "SSYExtrospectiveViewController.h"
32
#import "SSYAlert.h"
43

54
NSString* SSYLazyViewErrorDomain = @"SSYLazyViewErrorDomain" ;
@@ -77,9 +76,11 @@ - (void)loadWithOwner:(id)owner {
7776
BOOL isMacOSX10_8orLater = [bundle respondsToSelector:@selector(loadNibNamed:owner:topLevelObjects:)] ;
7877

7978
if (isMacOSX10_8orLater) {
79+
#pragma deploymate push "ignored-api-availability" // Skip it until next "pop"
8080
ok = [bundle loadNibNamed:nibName
8181
owner:owner
8282
topLevelObjects:&topLevelObjects] ;
83+
#pragma deploymate pop
8384
if (ok) {
8485
// See details of doc for -loadNibNamed:owner:topLevelObjects:,
8586
// https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW6

SSYOperation.h

+18-1
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,27 @@
8181
- (NSError*)error ;
8282

8383
/*!
84-
@brief Sets the error of the receiver's operation queue.
84+
@brief Sets the error of the receiver's operation queue, and into the
85+
userInfo dictionary of the error, adds key constKeySSYOperationGroup
86+
with value equal to the name of the receiver's operation group
87+
88+
@details Due to the addition of constKeySSYOperationGroup in the error's
89+
userInfo, when other operations in the receiver's queue receive an -error
90+
message, they will only return the error given here if their operation group's
91+
name is the same as that of the receiver of this message.
8592
*/
8693
- (void)setError:(NSError*)error ;
8794

95+
/*!
96+
@brief Sets the error of the receiver's operation queue, without adding
97+
key constKeySSYOperationGroup to the userInfo of the error
98+
99+
@details Due to the non-addition of constKeySSYOperationGroup in the error's
100+
userInfo, when other operations in the receiver's queue receive an -error
101+
message, they will always return the error given here.
102+
*/
103+
- (void)setAllGroupsError:(NSError*)error ;
104+
88105
/*!
89106
@brief Appends the suffix _unsafe to the name of a given selector
90107
and performs the _unsafe selector on the main thread, making it safe(r).

SSYOperation.m

+6
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ - (void)setError:(NSError*)error {
118118
operation:self] ;
119119
}
120120

121+
- (void)setAllGroupsError:(NSError*)error {
122+
[[self operationQueue] setError:error
123+
operation:nil] ;
124+
}
125+
126+
121127
- (NSString*)description {
122128
NSString* selectorName = NSStringFromSelector([self selector]) ;
123129
if ([selectorName isEqualToString:@"doDone:"]) {

SSYOperationQueue.m

+4
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ - (void)observeValueForKeyPath:(NSString*)keyPath
238238
// responds to -beginActivityWithOptions:reason:,
239239
// which means that it should also respond to -endActivity:
240240
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(endActivity:)]) {
241+
#pragma deploymate push "ignored-api-availability" // Skip this until matching "pop"
241242
[[NSProcessInfo processInfo] endActivity:activity] ;
243+
#pragma deploymate pop
242244
}
243245
}
244246
#endif
@@ -282,8 +284,10 @@ - (void)observeValueForKeyPath:(NSString*)keyPath
282284
@"SSYOperations beginning with group %@ at %@",
283285
groupName,
284286
[[NSDate date] geekDateTimeString]] ;
287+
#pragma deploymate push "ignored-api-availability" // Skip it until next "pop"
285288
id activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityAutomaticTerminationDisabled
286289
reason:reason] ;
290+
#pragma deploymate pop
287291
[self setNoAppNapActivity:activity] ;
288292
}
289293
#endif

SSYPersistentDocumentMultiMigrator.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#import "NSDocument+SyncModDate.h"
77
#import "NSError+Recovery.h"
88
#import "NSBundle+MainApp.h"
9+
#import "NSDocument+SSYAutosaveBetter.h"
10+
911

1012
NSString* const SSYPersistentDocumentMultiMigratorErrorDomain = @"SSYPersistentDocumentMultiMigratorErrorDomain" ;
1113
NSString* const SSYPersistentDocumentMultiMigratorDidBeginMigrationNotification = @"SSYPersistentDocumentMultiMigratorDidBeginMigrationNotification" ;
@@ -255,7 +257,7 @@ + (BOOL)migrateIfNeededStoreAtUrl:(NSURL*)url
255257
// Fix in BookMacster 1.18.1, for Mac OS X 10.6
256258
BOOL isInViewingMode = NO ;
257259
if ([document respondsToSelector:@selector(isInViewingMode)]) {
258-
isInViewingMode = [document isInViewingMode] ;
260+
isInViewingMode = [document ssy_isInViewingMode] ;
259261
}
260262
#if 0
261263
// Fix 20130610 - Does not work.

SSYProcessTyper.m

+2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ + (NSInteger)weGotMenuBar {
154154
&&
155155
[[NSWorkspace sharedWorkspace] respondsToSelector:@selector(menuBarOwningApplication)]
156156
) {
157+
#pragma deploymate push "ignored-api-availability" // Skip it until next "pop"
157158
NSRunningApplication* menuBarApp = [[NSWorkspace sharedWorkspace] menuBarOwningApplication] ;
159+
#pragma deploymate pop
158160
BOOL weGotMenuBar = ([menuBarApp isEqual:[NSRunningApplication currentApplication]]) ;
159161
answer = weGotMenuBar ? NSOnState : NSOffState ;
160162
}

0 commit comments

Comments
 (0)