예제 #1
0
파일: control.c 프로젝트: eldesh/smlsharp
static void
activate(struct sml_control *control)
{
	unsigned int old;

	/* lock; all updates so far must be acquired */
	old = fetch_and(acquire, &control->state, ~INACTIVE_FLAG);
	if (IS_ACTIVE(old)) {
		mutex_lock(&control->inactive_wait_lock);
		pthread_cleanup_push(cleanup_mutex_unlock,
				     &control->inactive_wait_lock);
		while ((old = fetch_and(acquire, &control->state,
					~INACTIVE_FLAG),
			IS_ACTIVE(old)))
			cond_wait(&control->inactive_wait_cond,
				  &control->inactive_wait_lock);
		pthread_cleanup_pop(1);
	}

	assert(IS_ACTIVE(load_relaxed(&control->state)));
}
예제 #2
0
 __host__ __device__
 int_type operator&=(int_type val) volatile
 {
   return fetch_and(val) + val;
 }
예제 #3
0
파일: atomic.hpp 프로젝트: robryk/www10
 T operator &= (T value)
 {
     return fetch_and(value) & value;
 }