标签:class com get strong string set
@property (nonatomic) dispatch_semaphore_t semaphore;
self.semaphore = dispatch_semaphore_create([self.progressViews count]);
dispatch_semaphore_wait(self.semaphore, DISPATCH_TIME_FOREVER);
dispatch_semaphore_signal(self.semaphore);
===================================================
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA_ADD/OR, 0, 0, dispatch_get_main_queue());
__block long totalComplete = 0;
dispatch_source_set_event_handler(source, ^{
long value = dispatch_source_get_data(source);
totalComplete += value;
self.progressView.progress = (CGFloat) totalComplete /100.0f;
});
dispatch_resume(source);
dispatch_queue_t
queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0);
dispatch_async(queue, ^{
for (int i = 0; i <= 100; ++i) {
dispatch_source_merge_data(source, 1);
usleep(20000);
}
});
=======
static char kMyKey;
CFStringRef *value = CFStringCreate...;
dispatch_queue_set_specific(queue,&kMyKey,(void*)value,(dispatch_function_t)CFRelease);
dispatch_sync(queue, ^{
CFStringRef *string = dispatch_get_specific(&kMyKey);
...
});
========
dispatch_queue_set_specific(q, &sQueueTagKey, (__bridge void*)q, NULL);
=============
Dispatch Data and Dispatch I/O
dispatch_io_t serverChannel = dispatch_io_create(DISPATCH_IO_STREAM, socket, queue,
^(int error) {
NSAssert(!error,
@"Failed socket:%d", error);
NSLog(@"Closing connection");
close(socket);
});
dispatch_data_create
NSString *writePath = [self outputFilePathForPath:path];
dispatch_io_t
fileChannel = dispatch_io_create_with_path(DISPATCH_IO_STREAM,
[writePath UTF8String],
O_WRONLY|O_CREAT|O_TRUNC,
S_IRWXU,
queue,
nil);
dispatch_io_write(serverChannel, 0, requestData, queue,
^(bool serverWriteDone,
dispatch_data_t serverWriteData,
int serverWriteError) {
NSAssert(!serverWriteError,
@"Server write error:%d", serverWriteError);
if (serverWriteDone) {
[self readFromChannel:serverChannel
} });
标签:class com get strong string set
原文地址:http://www.cnblogs.com/anjsxz/p/3772659.html