Example #1
0
Galois::Runtime::LockManagerBase::AcquireStatus
Galois::Runtime::LockManagerBase::tryAcquire(Galois::Runtime::Lockable* lockable) 
{
  assert(lockable);
  // XXX(ddn): Hand inlining this code makes a difference on 
  // delaunaytriangulation (GCC 4.7.2)
#if 0
  if (tryLock(lockable)) {
    assert(!getOwner(lockable));
    ownByForce(lockable);
    return NEW_OWNER;
#else
  if (lockable->owner.try_lock()) {
    lockable->owner.setValue(this);
    return NEW_OWNER;
#endif
  } else if (getOwner(lockable) == this) {
    return ALREADY_OWNER;
  }
  return FAIL;
}

void Galois::Runtime::SimpleRuntimeContext::acquire(Galois::Runtime::Lockable* lockable) {
  AcquireStatus i;
  if (customAcquire) {
    subAcquire(lockable);
  } else if ((i = tryAcquire(lockable)) != AcquireStatus::FAIL) {
    if (i == AcquireStatus::NEW_OWNER) {
      addToNhood(lockable);
    }
  } else {
    Galois::Runtime::signalConflict(lockable);
  }
}
 bool ISemaphore::tryAcquire(long timeoutInMillis) {
     return tryAcquire(1, timeoutInMillis);
 }
 bool ISemaphore::tryAcquire() {
     return tryAcquire(int(1));
 }