Conversation
Block may not be called when the user sends message to TMCache instance, which will cause some problems.
|
At first glance this doesn’t look like something we’d want to add. Can you explain what problems this fixes? |
- (void)deadLockMethod
{
__block id objectForKey = nil;
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
// user should wait the signal, but the key is nil and then block will never be called.
[[TMCache sharedCache] objectForKey:nil block:^(TMCache *cache, NSString *key, id object) {
objectForKey = object;
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
} |
|
Passing a Additionally, your example above is a bit too contrived to be compelling, as you wouldn’t use a semaphore to synchronize |
|
It is just a example, my point is library should consider the exception input, and the asynchronous APIs should notify caller in all conditions including exception conditions. |
|
@xinjixjz 这个提交挺好啊!他不给你合并,可惜了。 |
Block may not be called when the user sends message to TMCache
instance, which will cause some problems.