本文整理汇总了C++中Condition类的典型用法代码示例。如果您正苦于以下问题:C++ Condition类的具体用法?C++ Condition怎么用?C++ Condition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Condition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timer_event_thread_proc
static void* timer_event_thread_proc(void*)
{
for (;;)
{
int status;
pthread_mutex_lock(&gTimerMutex);
timespec spec = gTimeSpec;
// mark our global to be zero
// so we don't call timedwait again on a stale value
gTimeSpec.tv_sec = 0;
gTimeSpec.tv_nsec = 0;
if (spec.tv_sec == 0 && spec.tv_nsec == 0)
status = pthread_cond_wait(&gTimerCond, &gTimerMutex);
else
status = pthread_cond_timedwait(&gTimerCond, &gTimerMutex, &spec);
if (status == 0) // someone signaled us with a new time
{
pthread_mutex_unlock(&gTimerMutex);
}
else
{
SkASSERT(status == ETIMEDOUT); // no need to unlock the mutex (its unlocked)
// this is the payoff. Signal the event queue to wake up
// and also check the delay-queue
gEventQCondition.broadcast();
}
}
return 0;
}
示例2: ALOGI
void RemoteDisplayClient::onDisplayError(int32_t error) {
ALOGI("onDisplayError error=%d", error);
Mutex::Autolock autoLock(mLock);
mDone = true;
mCondition.broadcast();
}
示例3: update
/* Updates an attribute that meets the condition
...With its new value */
void Database::update(string rname, vector<string> attributes, vector<_Data> newvalues, Condition& c)
{
int indr = 0;
for (indr = 0; indr < allRelations.size(); ++indr)
{
if (allRelations[indr].GetName() == rname)
break;
}
_Relation r2 = *(c.evaluate(&allRelations[indr]));
for (int i = 0; i < r2.Columns[0].Rows.size(); ++i) {
for (int j = 0; j < allRelations[indr].Columns[0].Rows.size(); ++j) {
bool upd = true;
for (int k = 0; k < allRelations[indr].Columns.size(); ++i) {
if (r2.Columns[k].Rows[i].Data != allRelations[indr].Columns[k].Rows[j].Data) {
upd = false;
break;
}
}
if (upd == true) {
for (int y = 0; y < attributes.size(); ++y) {
for (int z = 0; z < allRelations[indr].Columns.size(); ++z) {
if (attributes[y] == allRelations[indr].Columns[z].Name) {
allRelations[indr].Columns[z].Rows[j] = newvalues[y];
}
}
}
}
}
}
}
开发者ID:Jac21,项目名称:CSCE-315-Team-Project-1--Relational-Database-Management-System--RDBMS-,代码行数:33,代码来源:Database.cpp
示例4: gridStartIterateFiltered
void gridStartIterateFiltered(int32_t x, int32_t y, uint32_t radius, PointTree::Filter *filter, Condition const &condition)
{
if (filter == NULL)
{
gridPointTree->query(x, y, radius);
}
else
{
gridPointTree->query(*filter, x, y, radius);
}
PointTree::ResultVector::iterator w = gridPointTree->lastQueryResults.begin(), i;
for (i = w; i != gridPointTree->lastQueryResults.end(); ++i)
{
BASE_OBJECT *obj = static_cast<BASE_OBJECT *>(*i);
if (!condition.test(obj)) // Check if we should skip this object.
{
filter->erase(gridPointTree->lastFilteredQueryIndices[i - gridPointTree->lastQueryResults.begin()]); // Stop the object from appearing in future searches.
}
else if (isInRadius(obj->pos.x - x, obj->pos.y - y, radius)) // Check that search result is less than radius (since they can be up to a factor of sqrt(2) more).
{
*w = *i;
++w;
}
}
gridPointTree->lastQueryResults.erase(w, i); // Erase all points that were a bit too far.
gridPointTree->lastQueryResults.push_back(NULL); // NULL-terminate the result.
gridIterator = &gridPointTree->lastQueryResults[0];
/*
// In case you are curious.
debug(LOG_WARNING, "gridStartIterateFiltered(%d, %d, %u) found %u objects", x, y, radius, (unsigned)gridPointTree->lastQueryResults.size() - 1);
*/
}
示例5: CombatConditionFunc
bool Combat::CombatConditionFunc(Creature* caster, Creature* target, const CombatParams& params, void*)
{
bool result = false;
for (const Condition* condition : params.conditionList) {
if (caster == target || !target->isImmune(condition->getType())) {
Condition* conditionCopy = condition->clone();
if (caster) {
conditionCopy->setParam(CONDITIONPARAM_OWNER, caster->getID());
}
//TODO: infight condition until all aggressive conditions has ended
result = target->addCombatCondition(conditionCopy);
}
}
return result;
}
示例6: getOwner
void MagicField::onStepInField(Creature* creature)
{
//remove magic walls/wild growth
if(id == ITEM_MAGICWALL || id == ITEM_WILDGROWTH || id == ITEM_MAGICWALL_SAFE || id == ITEM_WILDGROWTH_SAFE || isBlocking())
{
if(!creature->isInGhostMode())
g_game.internalRemoveItem(this, 1);
return;
}
const ItemType& it = items[getID()];
if(it.condition)
{
Condition* conditionCopy = it.condition->clone();
uint32_t ownerId = getOwner();
if(ownerId)
{
bool harmfulField = true;
if(g_game.getWorldType() == WORLD_TYPE_NO_PVP || getTile()->hasFlag(TILESTATE_NOPVPZONE))
{
Creature* owner = g_game.getCreatureByID(ownerId);
if(owner)
{
if(owner->getPlayer() || (owner->isSummon() && owner->getMaster()->getPlayer()))
harmfulField = false;
}
}
Player* targetPlayer = creature->getPlayer();
if(targetPlayer)
{
Player* attackerPlayer = g_game.getPlayerByID(ownerId);
if(attackerPlayer)
{
if(Combat::isProtected(attackerPlayer, targetPlayer))
harmfulField = false;
}
}
if(!harmfulField || (OTSYS_TIME() - createTime <= 5000) || creature->hasBeenAttacked(ownerId))
conditionCopy->setParam(CONDITIONPARAM_OWNER, ownerId);
}
creature->addCondition(conditionCopy);
}
}
示例7: onEndCondition
void Creature::executeConditions(uint32_t interval)
{
for(ConditionList::iterator it = conditions.begin(); it != conditions.end();){
if(!(*it)->onTick(this, interval)){
Condition* condition = *it;
onEndCondition(condition);
it = conditions.erase(it);
condition->onEnd(this, CONDITIONEND_DURATION);
onEndCondition(condition, false);
delete condition;
}
else{
++it;
}
}
}
示例8: deq
ThreadReturnType PEGASUS_THREAD_CDECL deq(void * parm)
{
Thread* my_thread = (Thread *)parm;
parmdef * Parm = (parmdef *)my_thread->get_parm();
MessageType type;
int first = Parm->first;
int second = Parm->second;
int count = Parm->count;
Condition * condstart = Parm->cond_start;
MessageQueue * mq = Parm->mq;
condstart->signal();
Message * message;
type = 0;
while (type != CLOSE_CONNECTION_MESSAGE)
{
message = mq->dequeue();
while (!message)
{
message = mq->dequeue();
}
type = message->getType();
delete message;
}
if (verbose)
{
#if defined (PEGASUS_OS_VMS)
//
// Threads::self returns long-long-unsigned.
//
printf("Received Cancel Message, %llu about to end\n", Threads::self());
#else
cout << "Received Cancel Message, " << Threads::self() <<
" about to end\n";
#endif
}
return ThreadReturnType(0);
}
示例9: onEndCondition
void Creature::removeConditions(ConditionEnd_t reason, bool onlyPersistent/* = true*/)
{
for(ConditionList::iterator it = conditions.begin(); it != conditions.end(); )
{
if(onlyPersistent && !(*it)->isPersistent())
{
++it;
continue;
}
Condition* condition = *it;
it = conditions.erase(it);
condition->endCondition(this, reason);
onEndCondition(condition->getType());
delete condition;
}
}
示例10: _l
bool
RawDumpCmdQueThread::
getCommand(sp<RawDumpCmdCookie> &rCmdCookie)
{
FUNCTION_IN;
//
bool ret = false;
//
Mutex::Autolock _l(mCmdMtx);
//
MY_LOGD("+ tid(%d), que size(%d)", ::gettid(), mCmdQ.size());
//
while ( mCmdQ.empty() && ! exitPending() )
{
mCmdCond.wait(mCmdMtx);
}
// get the latest frame, e.g. drop the
if ( !mCmdQ.empty() )
{
rCmdCookie = *mCmdQ.begin();
mCmdQ.erase(mCmdQ.begin());
ret = true;
MY_LOGD(" frame[%d] in slot[%d] is dequeued.", rCmdCookie->getFrameCnt(),rCmdCookie->getFrameCnt() );
}
//
MY_LOGD("- tid(%d), que size(%d), ret(%d)", ::gettid(), mCmdQ.size(), ret);
//
FUNCTION_OUT;
//
return ret;
}
示例11: _l
//-----------------------------------------------------------------------------
MBOOL
CapBufMgrImp::
pushBuf(IImageBuffer* pImageBuffer, MBOOL const isFullSize)
{
Mutex::Autolock _l(mLock);
//
MY_LOGD("(%d),Buf(0x%08X),TS(%d.%06d)",
isFullSize,
(MUINT32)pImageBuffer,
(MUINT32)((pImageBuffer->getTimestamp()/1000)/1000000),
(MUINT32)((pImageBuffer->getTimestamp()/1000)%1000000));
//
mlpImgBuf.push_back(pImageBuffer);
if(pImageBuffer->getTimestamp() > 0)
{
mCond.signal();
}
//
if(!mbUse)
{
mbUse = MTRUE;
}
//
return MTRUE;
}
示例12: mg
//flushes current_, and leaves a new current in place, which might have some
//data left over from the last one.
void
DestThreadedBufferPriv::bufswap()
{
ByteBuf * b = current_ ;
current_ = NULL;
ByteBufPtr prev = b ;
{
MutexGuard mg(lock_);
if( puterr_ )
{
PANICV( errbuf_.c_str());
}
if( available_.empty())
{
flush_.wait( mg );
}
if( puterr_ )
{
PANICV( errbuf_.c_str());
}
if( available_.empty())
{
PANICV( "no buffers available after flush");
}
current_ = available_.front();
available_.pop_front();
}
//put the unpushed portion of old current_ onto new one.
current_->reset();
writeq_->push( prev.release());
}
示例13: addJob
void addJob(const blocking_job &job)
{
MutexGuard lock(&mutex_);
queue_.push_back(job);
cond_.notify();
}
示例14: main
int main()
{
SetConsoleTitle("Login server for Knight Online v" STRINGIFY(__VERSION));
#ifdef WIN32
// Override the console handler
SetConsoleCtrlHandler(_ConsoleHandler, TRUE);
#endif
HookSignals(&s_hEvent);
g_pMain = new LoginServer();
// Startup server
if (g_pMain->Startup())
{
printf("\nServer started up successfully!\n");
// Wait until console's signaled as closing
s_hEvent.Wait();
}
else
{
#ifdef WIN32
system("pause");
#endif
}
printf("Server shutting down, please wait...\n");
delete g_pMain;
UnhookSignals();
return 0;
}
示例15: _lock
bool
ImageCreateThread::
getCommand(Command& rCmd)
{
bool ret = false;
//
Mutex::Autolock _lock(mCmdQueMtx);
//
MY_LOGD_IF(ENABLE_LOG_PER_FRAME, "+ que size(%d)", mCmdQue.size());
//
// Wait until the queue is not empty or this thread will exit.
while ( mCmdQue.empty() && ! exitPending() )
{
status_t status = mCmdQueCond.wait(mCmdQueMtx);
if ( NO_ERROR != status )
{
MY_LOGW("wait status(%d), que size(%d), exitPending(%d)", status, mCmdQue.size(), exitPending());
}
}
//
if ( ! mCmdQue.empty() )
{
// If the queue is not empty, take the first command from the queue.
ret = true;
rCmd = *mCmdQue.begin();
mCmdQue.erase(mCmdQue.begin());
MY_LOGD("command:%s", rCmd.name());
}
//
MY_LOGD_IF(ENABLE_LOG_PER_FRAME, "- que size(%d), ret(%d)", mCmdQue.size(), ret);
return ret;
}