本文整理汇总了C++中dispatch_release函数的典型用法代码示例。如果您正苦于以下问题:C++ dispatch_release函数的具体用法?C++ dispatch_release怎么用?C++ dispatch_release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dispatch_release函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: DNSXRefDeAlloc
void DNSXRefDeAlloc(DNSXConnRef connRef)
{
if (connRef == NULL)
{
os_log(OS_LOG_DEFAULT, "dns_services: DNSXRefDeAlloc called with NULL DNSXConnRef");
return;
}
// Schedule this work on the internal library queue
dispatch_sync(connRef->lib_q, ^{
xpc_connection_set_event_handler((connRef)->conn_ref, ^(__unused xpc_object_t event){}); // ignore any more events
xpc_release(connRef->conn_ref);
connRef->conn_ref = NULL;
dispatch_release(connRef->lib_q);
connRef->lib_q = NULL;
connRef->AppCallBack = NULL;
os_log_info(OS_LOG_DEFAULT, "dns_services: DNSXRefDeAlloc successfully DeAllocated conn_ref & lib_q");
dispatch_async((connRef)->client_q, ^{
dispatch_release(connRef->client_q);
connRef->client_q = NULL;
free(connRef);
os_log_info(OS_LOG_DEFAULT, "dns_services: DNSXRefDeAlloc successfully DeAllocated client_q & freed connRef");
});
});
开发者ID:Paxxi,项目名称:mDNSResponder,代码行数:25,代码来源:dns_services.c
示例2: smb_gss_get_cred_list
int
smb_gss_get_cred_list(struct smb_gss_cred_list **list, gss_OID mech)
{
struct cred_iter_ctx ctx;
ctx.s = dispatch_semaphore_create(0);
if (ctx.s == NULL)
return ENOMEM;
ctx.clist = malloc(sizeof (struct smb_gss_cred_list));
if (ctx.clist == NULL) {
dispatch_release(ctx.s);
return ENOMEM;
}
TAILQ_INIT(ctx.clist);
gss_iter_creds_f(NULL, 0, mech, &ctx, cred_iter);
dispatch_semaphore_wait(ctx.s, DISPATCH_TIME_FOREVER);
dispatch_release(ctx.s);
*list = ctx.clist;
return 0;
}
开发者ID:B1NG0,项目名称:cifs,代码行数:25,代码来源:gss.c
示例3: _dispatch_transform_buffer_new
static bool
_dispatch_transform_buffer_new(dispatch_transform_buffer_s *buffer,
size_t required, size_t size)
{
size_t remaining = buffer->size - (buffer->ptr.u8 - buffer->start);
if (required == 0 || remaining < required) {
if (buffer->start) {
if (buffer->ptr.u8 > buffer->start) {
dispatch_data_t _new = dispatch_data_create(buffer->start,
buffer->ptr.u8 - buffer->start, NULL,
DISPATCH_DATA_DESTRUCTOR_FREE);
dispatch_data_t _concat = dispatch_data_create_concat(
buffer->data, _new);
dispatch_release(_new);
dispatch_release(buffer->data);
buffer->data = _concat;
} else {
free(buffer->start);
}
}
buffer->size = required + size;
buffer->start = NULL;
if (buffer->size > 0) {
if (buffer->size > BUFFER_MALLOC_MAX) {
return false;
}
buffer->start = (uint8_t*)malloc(buffer->size);
if (buffer->start == NULL) {
return false;
}
}
buffer->ptr.u8 = buffer->start;
}
return true;
}
开发者ID:ourui,项目名称:libdispath-linux,代码行数:35,代码来源:transform.c
示例4: dispatch_test_check_evfilt_vm
static bool
dispatch_test_check_evfilt_vm(void)
{
int kq = kqueue();
assert(kq != -1);
struct kevent ke = {
.filter = EVFILT_VM,
.flags = EV_ADD|EV_ENABLE|EV_RECEIPT,
.fflags = NOTE_VM_PRESSURE,
};
int r = kevent(kq, &ke, 1, &ke, 1, NULL);
close(kq);
return !(r > 0 && ke.flags & EV_ERROR && ke.data == ENOTSUP);
}
static void
cleanup(void)
{
dispatch_source_cancel(vm_source);
dispatch_release(vm_source);
dispatch_release(vm_queue);
int32_t pc = 0, i;
for (i = 0; i < max_page_count; ++i) {
if (pages[i]) {
pc++;
free(pages[i]);
}
}
if (pc) {
log_msg("Freed %ldMB\n", pg2mb(pc));
}
free(pages);
test_stop();
}
开发者ID:PSPDFKit-labs,项目名称:libdispatch,代码行数:35,代码来源:dispatch_vm.c
示例5: gcdpoll_watch_free
static void
gcdpoll_watch_free(AvahiWatch *w)
{
AvahiWatch *prev;
AvahiWatch *cur;
if (w->w_read)
{
dispatch_source_cancel(w->w_read);
dispatch_release(w->w_read);
}
if (w->w_write)
{
dispatch_source_cancel(w->w_write);
dispatch_release(w->w_write);
}
prev = NULL;
for (cur = all_w; cur; prev = cur, cur = cur->next)
{
if (cur != w)
continue;
if (prev == NULL)
all_w = w->next;
else
prev->next = w->next;
break;
}
free(w);
}
开发者ID:Deledrius,项目名称:forked-daapd,代码行数:34,代码来源:mdns_avahi.c
示例6: mdns_deinit_task
static void
mdns_deinit_task(void *arg)
{
struct mdns_group_entry *ge;
struct mdns_browser *mb;
AvahiWatch *w;
AvahiTimeout *t;
if (mdns_client)
avahi_client_free(mdns_client);
for (t = all_t; t; t = t->next)
{
if (t->timer)
{
dispatch_source_cancel(t->timer);
dispatch_release(t->timer);
t->timer = NULL;
}
}
for (w = all_w; w; w = w->next)
{
if (w->w_read)
{
dispatch_source_cancel(w->w_read);
dispatch_release(w->w_read);
}
if (w->w_write)
{
dispatch_source_cancel(w->w_write);
dispatch_release(w->w_write);
}
}
for (ge = group_entries; group_entries; ge = group_entries)
{
group_entries = ge->next;
free(ge->name);
free(ge->type);
avahi_string_list_free(ge->txt);
free(ge);
}
for (mb = browser_list; browser_list; mb = browser_list)
{
browser_list = mb->next;
free(mb->type);
free(mb);
}
}
开发者ID:Deledrius,项目名称:forked-daapd,代码行数:55,代码来源:mdns_avahi.c
示例7: timer_free
/*
* This does the actual free.
* It is dispatched on the timer's dispatch source queue to make it safe.
*/
static void
timer_free(timer_t *t)
{
if (t == NULL) return;
if (t->deactivation_handler != NULL) Block_release(t->deactivation_handler);
if (t->contextp != NULL) free(t->contextp);
dispatch_release(t->t_src);
dispatch_release(t->t_queue);
memset(t, 0, sizeof(timer_t));
free(t);
}
开发者ID:010001111,项目名称:darling,代码行数:17,代码来源:timer.c
示例8: cancelRepeatingTimer
static void cancelRepeatingTimer(struct nodeInstanceData *ctx)
{
dispatch_source_cancel(ctx->timer);
dispatch_release(ctx->timer);
ctx->timer = NULL;
dispatch_semaphore_wait(ctx->timerCanceled, DISPATCH_TIME_FOREVER);
}
开发者ID:AlexanderMazaletskiy,项目名称:vuo,代码行数:7,代码来源:vuo.test.firePeriodicallyWithCount.c
示例9: execute_sectransform
static dispatch_data_t
execute_sectransform(SecTransformRef transformRef, dispatch_data_t data)
{
const void * bytes;
size_t size;
dispatch_data_t map = dispatch_data_create_map(data, &bytes, &size);
assert(map);
CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, bytes, size);
assert(dataRef);
dispatch_release(map);
SecTransformSetAttribute(transformRef, kSecTransformInputAttributeName, dataRef, NULL);
CFDataRef transformedDataRef = SecTransformExecute(transformRef, NULL);
assert(transformedDataRef);
CFRelease(dataRef);
dispatch_data_t output = dispatch_data_create(CFDataGetBytePtr(transformedDataRef), CFDataGetLength(transformedDataRef), dispatch_get_main_queue(), DISPATCH_DATA_DESTRUCTOR_DEFAULT);
CFRelease(transformedDataRef);
return output;
}
开发者ID:RLovelett,项目名称:swift-corelibs-libdispatch,代码行数:26,代码来源:dispatch_transform.c
示例10: PJ_DEF
/*
* pj_sem_destroy()
*/
PJ_DEF(pj_status_t) pj_sem_destroy(pj_sem_t *sem)
{
#if PJ_HAS_THREADS
int result;
PJ_CHECK_STACK();
PJ_ASSERT_RETURN(sem, PJ_EINVAL);
PJ_LOG(6, (sem->obj_name, "Semaphore destroyed by thread %s",
pj_thread_this(sem->inst_id)->obj_name));
#if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
#if 1
dispatch_release(sem->sem);
result = 0;
#else
result = sem_close( sem->sem );
#endif
#else
result = sem_destroy( sem->sem );
#endif
if (result == 0)
return PJ_SUCCESS;
else
return PJ_RETURN_OS_ERROR(pj_get_native_os_error());
#else
pj_assert( sem == (pj_sem_t*) 1 );
return PJ_SUCCESS;
#endif
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:33,代码来源:os_core_unix.c
示例11: test_timer
void
test_timer(void)
{
dispatch_test_start("Dispatch Update Timer");
dispatch_queue_t main_q = dispatch_get_main_queue();
//test_ptr("dispatch_get_main_queue", main_q, dispatch_get_current_queue());
__block int i = 0;
struct timeval start_time;
gettimeofday(&start_time, NULL);
dispatch_source_t s = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, main_q);
test_ptr_notnull("dispatch_source_create", s);
dispatch_source_set_timer(s, dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC), NSEC_PER_SEC, 0);
dispatch_source_set_cancel_handler(s, ^{
struct timeval end_time;
gettimeofday(&end_time, NULL);
// Make sure we actually managed to adjust the interval
// duration. Seven one second ticks would blow past
// this.
test_long_less_than("total duration", end_time.tv_sec - start_time.tv_sec, 3);
test_stop();
dispatch_release(s);
});
开发者ID:AlexShiLucky,项目名称:swift-corelibs-libdispatch,代码行数:29,代码来源:dispatch_timer_set_time.c
示例12: SDMMD_USBMuxListenerSend
void SDMMD_USBMuxListenerSend(SDMMD_USBMuxListenerRef listener, struct USBMuxPacket **packet) {
listener->ivars.semaphore = dispatch_semaphore_create(0x0);
SDMMD_USBMuxSend(listener->ivars.socket, *packet);
dispatch_semaphore_wait(listener->ivars.semaphore, (*packet)->timeout);
CFMutableArrayRef updateWithRemove = CFArrayCreateMutableCopy(kCFAllocatorDefault, 0x0, listener->ivars.responses);
struct USBMuxPacket *responsePacket = NULL;
uint32_t removeCounter = 0x0;
for (uint32_t i = 0x0; i < CFArrayGetCount(listener->ivars.responses); i++) {
struct USBMuxPacket *response = (struct USBMuxPacket *)CFArrayGetValueAtIndex(listener->ivars.responses, i);
if ((*packet)->body.tag == response->body.tag) {
responsePacket = response;
CFArrayRemoveValueAtIndex(updateWithRemove, i-removeCounter);
removeCounter++;
}
}
CFSafeRelease(listener->ivars.responses);
listener->ivars.responses = CFArrayCreateMutableCopy(kCFAllocatorDefault, 0x0, updateWithRemove);
CFSafeRelease(updateWithRemove);
USBMuxPacketRelease(*packet);
if (!responsePacket) {
responsePacket = (struct USBMuxPacket *)calloc(0x1, sizeof(struct USBMuxPacket));
}
*packet = responsePacket;
dispatch_release(listener->ivars.semaphore);
}
开发者ID:bigfei,项目名称:SDMMobileDevice,代码行数:26,代码来源:SDMMD_USBMux_Protocol.c
示例13: do_test
static void do_test(void)
{
size_t i;
char buf[1000];
dispatch_group_t g = dispatch_group_create();
for (i = 0; i < QUEUES; i++) {
#ifdef WIN32
_snprintf(buf, sizeof(buf), "com.example.memoryload-node#%ld", i);
#else
snprintf(buf, sizeof(buf), "com.example.memoryload-node#%ld", (long int)i);
#endif
queues[i] = dispatch_queue_create(buf, NULL);
dispatch_suspend(queues[i]);
}
for (i = 0; i < QUEUES; i++) {
dispatch_group_async_f(g, queues[i], g, start_node);
}
dispatch_group_notify_f(g, dispatch_get_main_queue(), NULL, collect);
for (i = 0; i < QUEUES; i++) {
dispatch_resume(queues[i]);
dispatch_release(queues[i]);
}
}
开发者ID:RunLoopStudio,项目名称:xdispatch,代码行数:27,代码来源:dispatch_memory_use.c
示例14: gcdpoll_timeout_free
static void
gcdpoll_timeout_free(AvahiTimeout *t)
{
AvahiTimeout *prev;
AvahiTimeout *cur;
if (t->timer)
{
dispatch_source_cancel(t->timer);
dispatch_release(t->timer);
t->timer = NULL;
}
prev = NULL;
for (cur = all_t; cur; prev = cur, cur = cur->next)
{
if (cur != t)
continue;
if (prev == NULL)
all_t = t->next;
else
prev->next = t->next;
break;
}
free(t);
}
开发者ID:Deledrius,项目名称:forked-daapd,代码行数:29,代码来源:mdns_avahi.c
示例15: mdns_deinit
void
mdns_deinit(void)
{
dispatch_sync_f(mdns_sq, NULL, mdns_deinit_task);
dispatch_release(mdns_sq);
}
开发者ID:Deledrius,项目名称:forked-daapd,代码行数:7,代码来源:mdns_avahi.c
示例16: halide_mutex_cleanup
WEAK void halide_mutex_cleanup(halide_mutex *mutex_arg) {
gcd_mutex *mutex = (gcd_mutex *)mutex_arg;
if (mutex->once != 0) {
dispatch_release(mutex->semaphore);
memset(mutex_arg, 0, sizeof(halide_mutex));
}
}
开发者ID:Shiryu19,项目名称:Halide,代码行数:7,代码来源:gcd_thread_pool.cpp
示例17: _notify_lib_port_proc_release
void
_notify_lib_port_proc_release(notify_state_t *ns, mach_port_t port, pid_t proc)
{
portproc_data_t *pdata = NULL;
if (ns == NULL) return;
if ((proc == 0) && (port == MACH_PORT_NULL)) return;
if (ns->lock != NULL) pthread_mutex_lock(ns->lock);
if (proc == 0) pdata = _nc_table_find_n(ns->port_table, port);
else pdata = _nc_table_find_n(ns->proc_table, proc);
if (pdata != NULL)
{
if (pdata->refcount > 0) pdata->refcount--;
if (pdata->refcount == 0)
{
if (proc == 0) _nc_table_delete_n(ns->port_table, port);
else _nc_table_delete_n(ns->proc_table, proc);
dispatch_source_cancel(pdata->src);
dispatch_release(pdata->src);
free(pdata);
}
}
if (ns->lock != NULL) pthread_mutex_unlock(ns->lock);
}
开发者ID:BelyyVedmak,项目名称:Libnotify,代码行数:30,代码来源:libnotify.c
示例18: mdns_init
int
mdns_init(void)
{
DPRINTF(E_DBG, L_MDNS, "Initializing Avahi mDNS\n");
all_w = NULL;
all_t = NULL;
group_entries = NULL;
browser_list = NULL;
mdns_sq = dispatch_queue_create("org.forked-daapd.mdns", NULL);
if (!mdns_sq)
{
DPRINTF(E_FATAL, L_MDNS, "mdns_init: Could not create dispatch queue\n");
return -1;
}
dispatch_sync_f(mdns_sq, NULL, mdns_init_task);
if (!mdns_client)
goto client_fail;
return 0;
client_fail:
dispatch_release(mdns_sq);
return -1;
}
开发者ID:Deledrius,项目名称:forked-daapd,代码行数:29,代码来源:mdns_avahi.c
示例19: test_fin
void
test_fin(void *cxt)
{
fprintf(stderr, "Called back every %llu us on average\n",
(delay/count)/NSEC_PER_USEC);
test_long_less_than("Frequency", 1, ceil((double)delay/(count*interval)));
int i;
for (i = 0; i < N; i++) {
dispatch_source_cancel(t[i]);
dispatch_release(t[i]);
}
dispatch_resume(q);
dispatch_release(q);
dispatch_release(g);
test_ptr("finalizer ran", cxt, cxt);
test_stop();
}
开发者ID:JackieXie168,项目名称:GCD,代码行数:17,代码来源:dispatch_timer_short.c
示例20: closeSocketClient
static void closeSocketClient(SocketClientRef client)
{
dispatch_resume(client->source);
dispatch_source_cancel(client->source);
dispatch_release(client->source);
close(client->fd);
free(client);
}
开发者ID:n3b,项目名称:CRESTService,代码行数:8,代码来源:CRESTService.c
注:本文中的dispatch_release函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论