static void
		pong(void *context)
{
	dispatch_queue_t this_q = (dispatch_queue_t)context;
	size_t replies = (size_t)dispatch_get_context(this_q);

	dispatch_set_context(this_q, (void *)--replies);
	if (!replies) {
		//MU_MESSAGE("collect from: %s\n", dispatch_queue_get_label(dispatch_get_current_queue()));
		dispatch_async_f(dispatch_get_main_queue(), NULL, collect);
	}
}
示例#2
0
void WorkQueue::executeFunction(void* context)
{
    WorkQueue* queue = static_cast<WorkQueue*>(dispatch_get_context(dispatch_get_current_queue()));
    OwnPtr<Function<void()> > function = adoptPtr(static_cast<Function<void()>*>(context));
    
    {
        MutexLocker locker(queue->m_isValidMutex);
        if (!queue->m_isValid)
            return;
    }

    (*function)();
}
示例#3
0
void WorkQueue::executeWorkItem(void* item)
{
    WorkQueue* queue = static_cast<WorkQueue*>(dispatch_get_context(dispatch_get_current_queue()));
    OwnPtr<WorkItem> workItem(static_cast<WorkItem*>(item));
    
    {
        MutexLocker locker(queue->m_isValidMutex);
        if (!queue->m_isValid)
            return;
    }
    
    workItem->execute();
}
示例#4
0
文件: mach.c 项目: Acorld/libxpc
static dispatch_source_t
mach_create_client_source(xpc_port_t port, void *context, dispatch_queue_t tq)
{
	mach_port_t mp = (mach_port_t)port;
	dispatch_source_t ret;

	ret = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV,
	    (uintptr_t)mp, 0, tq);

	dispatch_set_context(ret, context);
	dispatch_source_set_event_handler_f(ret, xpc_connection_recv_message);
	dispatch_source_set_cancel_handler(ret, ^{
	    xpc_connection_destroy_peer(dispatch_get_context(ret));
	});