当前位置: 首页>>代码示例>>C++>>正文


C++ Cond类代码示例

本文整理汇总了C++中Cond的典型用法代码示例。如果您正苦于以下问题:C++ Cond类的具体用法?C++ Cond怎么用?C++ Cond使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cond类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_conditional_chain_callback

void Parser::IncludedFile::WalkThrough::enter_conditional_chain(CondChain *cc)
{
	CListEntry *i, *j;
#if SANITY_CHECK
	unsigned sum = 0;
	unsigned has_else = 0;
#endif

	if(method == MED_BF && on_conditional_chain_callback)
		on_conditional_chain_callback(context, cc);
	for(i = cc->chain.next; i != &cc->chain; i = j) {
		j = i->next;
		Cond *c = container_of(i, Cond, link);
#if SANITY_CHECK
		sum += c->value;
		has_else += (c->type == Cond::CT_ELSE);
#endif
		c->sanity_check();
		enter_conditional(c);
	}
#if SANITY_CHECK
	char emsg[256] = {0x1} ;
	if(sum > 1)
		snprintf(emsg, sizeof(emsg), "Has %u true conditionals", sum);
	if(has_else && sum != 1)
		snprintf(emsg, sizeof(emsg), "A chain with else has %u true conditionals", sum);
	if(emsg[0] != '\x1')
		dump_and_exit(cc, emsg);
#endif
	if(method == MED_DF && on_conditional_chain_callback)
		on_conditional_chain_callback(context, cc);
}
开发者ID:panruochen,项目名称:codeless,代码行数:32,代码来源:Parser.cpp

示例2: Cancel

 void Cancel() {
   const ScopeLock lock(mutex);
   if (!cancel_flag) {
     cancel_flag = true;
     cancel_cond.signal();
   }
 }
开发者ID:Advi42,项目名称:XCSoar,代码行数:7,代码来源:ThreadedOperationEnvironment.hpp

示例3: runChecks

void PendingChecks::runChecks()
{
    DynMutex::Guard guard = m_mutex.lock();
    Checks::iterator it = m_checks.begin();
    bool removed = false;
    while (it != m_checks.end()) {
        bool cont;
        try {
            cont = (**it)();
        } catch (...) {
            Exception::handle(HANDLE_EXCEPTION_FATAL);
            // keep compiler happy
            cont = false;
        }

        if (!cont) {
            // Done with this check
            Checks::iterator next = it;
            ++next;
            m_checks.erase(it);
            it = next;
            removed = true;
        } else {
            ++it;
        }
    }
    // Tell blockOnCheck() calls that they may have completed.
    if (removed) {
        m_cond.signal();
    }
}
开发者ID:freedesktop-unofficial-mirror,项目名称:SyncEvolution__syncevolution,代码行数:31,代码来源:GLibSupport.cpp

示例4: lookup

  VPtr lookup(const K& key) {
    VPtr val;
    list<VPtr> to_release;
    {
      Mutex::Locker l(lock);
      ++waiting;
      bool retry = false;
      do {
	retry = false;
	typename map<K, pair<WeakVPtr, V*>, C>::iterator i = weak_refs.find(key);
	if (i != weak_refs.end()) {
	  val = i->second.first.lock();
	  if (val) {
	    lru_add(key, val, &to_release);
	  } else {
	    retry = true;
	  }
	}
	if (retry)
	  cond.Wait(lock);
      } while (retry);
      --waiting;
    }
    return val;
  }
开发者ID:Carudy,项目名称:ceph,代码行数:25,代码来源:shared_cache.hpp

示例5: assert

bool
KRT2Device::Send(const uint8_t *msg, unsigned msg_size,
                 OperationEnvironment &env)
{
  //! Number of tries to send a message
  unsigned retries = NR_RETRIES;

  assert(msg_size > 0);

  do {
    response_mutex.Lock();
    response = NO_RSP;
    response_mutex.Unlock();
    // Send the message
    if (!port.FullWrite(msg, msg_size, env, CMD_TIMEOUT))
      return false;
    // Wait for the response
    response_mutex.Lock();
    rx_cond.timed_wait(response_mutex, CMD_TIMEOUT);
    auto _response = response;
    response_mutex.Unlock();

    if (_response == ACK)
      // ACK received, finish
      return true;

    // No ACK received, retry
    retries--;
  } while (retries);

  return false;
}
开发者ID:Andy-1954,项目名称:XCSoar,代码行数:32,代码来源:KRT2.cpp

示例6: lower_bound

  VPtr lower_bound(const K& key) {
    VPtr val;
    list<VPtr> to_release;
    {
      Mutex::Locker l(lock);
      bool retry = false;
      do {
	retry = false;
	if (weak_refs.empty())
	  break;
	typename map<K, WeakVPtr>::iterator i = weak_refs.lower_bound(key);
	if (i == weak_refs.end())
	  --i;
	val = i->second.lock();
	if (val) {
	  lru_add(i->first, val, &to_release);
	} else {
	  retry = true;
	}
	if (retry)
	  cond.Wait(lock);
      } while (retry);
    }
    return val;
  }
开发者ID:jinghai,项目名称:ceph,代码行数:25,代码来源:shared_cache.hpp

示例7: lookup_or_create

  VPtr lookup_or_create(const K &key) {
    VPtr val;
    list<VPtr> to_release;
    {
      Mutex::Locker l(lock);
      bool retry = false;
      do {
	retry = false;
	typename map<K, pair<WeakVPtr, V*>, C>::iterator i = weak_refs.find(key);
	if (i != weak_refs.end()) {
	  val = i->second.first.lock();
	  if (val) {
	    lru_add(key, val, &to_release);
	    return val;
	  } else {
	    retry = true;
	  }
	}
	if (retry)
	  cond.Wait(lock);
      } while (retry);

      V *new_value = new V();
      VPtr new_val(new_value, Cleanup(this, key));
      weak_refs.insert(make_pair(key, make_pair(new_val, new_value)));
      lru_add(key, new_val, &to_release);
      return new_val;
    }
  }
开发者ID:Carudy,项目名称:ceph,代码行数:29,代码来源:shared_cache.hpp

示例8: Trigger

 /**
  * Wakes up the thread to do work, calls tick().
  */
 void Trigger() {
   const ScopeLock lock(mutex);
   if (!trigger_flag) {
     trigger_flag = true;
     trigger_cond.signal();
   }
 }
开发者ID:MaxPower-No1,项目名称:XCSoar,代码行数:10,代码来源:WorkerThread.hpp

示例9: remove

 void remove(const K& key, V *valptr) {
   Mutex::Locker l(lock);
   typename map<K, pair<WeakVPtr, V*>, C>::iterator i = weak_refs.find(key);
   if (i != weak_refs.end() && i->second.second == valptr) {
     weak_refs.erase(i);
   }
   cond.Signal();
 }
开发者ID:Carudy,项目名称:ceph,代码行数:8,代码来源:shared_cache.hpp

示例10: Set

  void Set(const K &key, const V &value) {
    auto i = map.insert(std::make_pair(key, Item(value)));
    Item &item = i.first->second;
    item.old = false;
    if (!i.second)
      item.value = value;

    cond.broadcast();
  }
开发者ID:Advi42,项目名称:XCSoar,代码行数:9,代码来源:SettingsMap.hpp

示例11: dev_stop_handler

void dev_stop_handler(int sig)
{
    XCAM_UNUSED (sig);

    SmartLock locker (g_mutex);
    g_stop = true;
    g_cond.broadcast ();

    //exit(0);
}
开发者ID:skibey,项目名称:libxcam,代码行数:10,代码来源:test-device-manager.cpp

示例12: leave

    void leave() const
    {
        Lock lock(mutex);

        assert(refcnt > 0);
        assert(pthread_equal(holder, pthread_self()) != 0);

        refcnt--;
        if (refcnt == 0)
        {
            cond.signal();
        }
    }
开发者ID:VonRosenchild,项目名称:debian-percona-galera-3,代码行数:13,代码来源:gu_monitor.hpp

示例13: lookup

  VPtr lookup(const K &key) {
    Mutex::Locker l(lock);
    while (1) {
      if (contents.count(key)) {
	VPtr retval = contents[key].lock();
	if (retval)
	  return retval;
      } else {
	break;
      }
      cond.Wait(lock);
    Mutex::Locker l(lock);
    }
    return VPtr();
  }
开发者ID:BillTheBest,项目名称:ceph,代码行数:15,代码来源:sharedptr_registry.hpp

示例14: lookup_or_create

  VPtr lookup_or_create(const K &key, const A &arg) {
    Mutex::Locker l(lock);
    while (1) {
      if (contents.count(key)) {
	VPtr retval = contents[key].lock();
	if (retval)
	  return retval;
      } else {
	break;
      }
      cond.Wait(lock);
    }
    VPtr retval(new V(arg), OnRemoval(this, key));
    contents[key] = retval;
    return retval;
  }
开发者ID:BillTheBest,项目名称:ceph,代码行数:16,代码来源:sharedptr_registry.hpp

示例15: Wait

  const_iterator Wait(const K &key, OperationEnvironment &env,
                      TimeoutClock timeout) {
    while (true) {
      auto i = map.find(key);
      if (i != map.end() && !i->second.old)
        return const_iterator(i);

      if (env.IsCancelled())
        return end();

      int remaining = timeout.GetRemainingSigned();
      if (remaining <= 0)
        return end();

      cond.timed_wait(*this, remaining);
    }
  }
开发者ID:Advi42,项目名称:XCSoar,代码行数:17,代码来源:SettingsMap.hpp


注:本文中的Cond类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。