Beispiel #1
0
void
mdns_deinit(void)
{
  dispatch_sync_f(mdns_sq, NULL, mdns_deinit_task);

  dispatch_release(mdns_sq);
}
Beispiel #2
0
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;
}
Beispiel #3
0
void
logger_reinit(void)
{
  if (!logger_sq)
    return;

  dispatch_sync_f(logger_sq, NULL, logger_reinit_task);
}
Beispiel #4
0
static VALUE
rb_queue_dispatch_sync(VALUE self, SEL sel)
{
    rb_vm_block_t *block = get_prepared_block();
    dispatch_sync_f(RQueue(self)->queue, (void *)block,
	    rb_block_dispatcher);

    return Qnil;
}
static void
apply_fn(void* ctxt, size_t idx)
{
    dispatch_sync_f(dq, NULL, reader);

    if (idx % INTERVAL) {
        dispatch_barrier_async_f(dq, NULL, writer);
    }
}
Beispiel #6
0
void GetGpsData( GPS_DATA_t *pData )
{
    if( !bInit )
    {
        InitGpsDataDispatchQueue();
    }

    dispatch_sync_f( queueGpsData, pData, PopGpsData );
}
Beispiel #7
0
DISPATCH_NOINLINE
void
dispatch_apply_f(size_t iterations, dispatch_queue_t dq, void *ctxt,
		void (*func)(void *, size_t))
{
	if (slowpath(iterations == 0)) {
		return;
	}

	dispatch_apply_t da = (typeof(da))_dispatch_continuation_alloc();

	da->da_func = func;
	da->da_ctxt = ctxt;
	da->da_iterations = iterations;
	da->da_index = 0;
	da->da_thr_cnt = _dispatch_hw_config.cc_max_active;
	da->da_done = 0;
	da->da_queue = NULL;

	if (da->da_thr_cnt > DISPATCH_APPLY_MAX_CPUS) {
		da->da_thr_cnt = DISPATCH_APPLY_MAX_CPUS;
	}
	if (iterations < da->da_thr_cnt) {
		da->da_thr_cnt = (uint32_t)iterations;
	}
	if (slowpath(dq->dq_width <= 2) || slowpath(da->da_thr_cnt <= 1) ||
			slowpath(_dispatch_thread_getspecific(dispatch_apply_key))) {
		return dispatch_sync_f(dq, da, _dispatch_apply_serial);
	}
	dispatch_queue_t old_dq = (dispatch_queue_t)
			_dispatch_thread_getspecific(dispatch_queue_key);
	if (slowpath(dq->do_targetq)) {
		if (slowpath(dq == old_dq)) {
			return dispatch_sync_f(dq, da, _dispatch_apply_serial);
		} else {
			da->da_queue = dq;
			return dispatch_sync_f(dq, da, _dispatch_apply_redirect);
		}
	}
	dispatch_atomic_acquire_barrier();
	_dispatch_thread_setspecific(dispatch_queue_key, dq);
	_dispatch_apply_f2(dq, da, _dispatch_apply2);
	_dispatch_thread_setspecific(dispatch_queue_key, old_dq);
}
Beispiel #8
0
void
rwsched_dispatch_sync_f(rwsched_tasklet_ptr_t sched_tasklet,
                        rwsched_dispatch_queue_t queue,
                        void *context,
                        dispatch_function_t handler)
{
  // Validate input paraemters
  RW_CF_TYPE_VALIDATE(sched_tasklet, rwsched_tasklet_ptr_t);
  rwsched_instance_ptr_t instance = sched_tasklet->instance;
  RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t);
  RW_ASSERT_TYPE(queue, rwsched_dispatch_queue_t);

  // If libdispatch is enabled for the entire instance, then call the libdispatch routine
  if (instance->use_libdispatch_only) {
    dispatch_sync_f(queue->header.libdispatch_object._dq, context, handler);
    return;
  }

  // Not yet implemented
  RW_CRASH();
}
Beispiel #9
0
void EnqueueTasks(const vector<Task *> &tasks) {
#ifdef PBRT_USE_GRAND_CENTRAL_DISPATCH
    static bool oneThread = (getenv("PBRT_NTHREADS") &&
                               atoi(getenv("PBRT_NTHREADS")) == 1);
    for (u_int i = 0; i < tasks.size(); ++i)
        if (oneThread)
            dispatch_sync_f(gcdQueue, tasks[i], lRunTask);
        else
            dispatch_group_async_f(gcdGroup, gcdQueue, tasks[i], lRunTask);
#else
    if (!threads)
        TasksInit();

    { MutexLock lock(*taskQueueMutex);
    for (unsigned int i = 0; i < tasks.size(); ++i)
        taskQueue.push_back(tasks[i]);
    }
    tasksRunningCondition.Lock();
    numUnfinishedTasks += tasks.size();
    tasksRunningCondition.Unlock();

    workerSemaphore.Post(tasks.size());
#endif
}
Beispiel #10
0
void queue::sync(
    operation *op
)
{
    dispatch_sync_f( d->native, op, _xdispatch_run_operation );
}
void SecOTRSessionReset(SecOTRSessionRef session)
{
    dispatch_sync_f(session->_queue, session, (dispatch_function_t) SecOTRSessionResetInternal);
}