void IesireDinWaiting5() { if(GetNrX()==0) { sleep(1); test("Verifica4",Verifica(1,0,1,0,0,1)==0); IncNrX(); Signal(m,1); sleep(1); test("Verifica5",Verifica(1,0,2,1,0,0)==0); Leave(m); return; } if(GetNrX()==1) { sleep(1); test("Verifica6",Verifica(1,0,1,1,0,0)==0); IncNrX(); Leave(m); return; } if(GetNrX()==2) { sleep(1); test("Verifica7",Verifica(1,0,0,2,0,0)==0); IncNrX(); Leave(m); return; } }
//! updates the visitor void FollowCameraPathVisitor::Update() { if(!m_bActive) { return; } f32 fRatio = m_fTimer/m_fDuration; m_pCamera->SetPosition(m_Path->GetPosition(m_CurrentElement, m_CurrentElement+1, fRatio)); m_pCamera->SetLookAt(m_Path->GetLookAt(m_CurrentElement, m_CurrentElement+1, fRatio)); if(m_fTimer < m_fDuration) { m_fTimer += g_fDeltaTime; } else if(m_CurrentElement < s32(m_Path->GetChildCount())-2) { ++m_CurrentElement; f32 newDuration = m_Path->GetElement(m_CurrentElement)->GetFollowDuration(); f32 fOverTime = (m_fTimer-m_fDuration)*(m_fDuration/newDuration); m_fDuration = newDuration-fOverTime; m_fTimer = fOverTime + g_fDeltaTime; } else { m_iPlayCount++; switch(m_ePlaybackType) { case PT_Once: Leave(); break; case PT_Loop: if((m_iMaxPlayCount < 0) || (m_iPlayCount < m_iMaxPlayCount)) { m_CurrentElement = 0; f32 newDuration = m_Path->GetElement(m_CurrentElement)->GetFollowDuration(); f32 fOverTime = (m_fTimer-m_fDuration)*(m_fDuration/newDuration); m_fDuration = newDuration-fOverTime; m_fTimer = fOverTime + g_fDeltaTime; } else { Leave(); } break; case PT_Toggle: SHOOT_WARNING(false, "FollowCameraPathVisitor Unsupported PlaybackType: PT_Toggle"); Leave(); break; default: Leave(); } } }
CLI CommonList::Find(void *data) { Enter(); for(CLI item = first; item; item = item->next) if(data == item->data) { Leave(); return item; } Leave(); return NULL; }
/** * @brief Decreases the amount of memory memory usage logged. * * @throws ErrorReport If integer overflow will occur. * * @param amount The amount to decrease memory usage logged by. */ void MemoryUsageLog::DecreaseMemorySize( size_t amount ) { Enter(); try { size_t newMemoryUsage = this->GetMemorySize() - amount; _ErrorException((amount > 0 && newMemoryUsage >= this->GetMemorySize()),"decreasing the logged memory usage of an object, integer overflow will occur",0,__LINE__,__FILE__); this->memoryUsage = newMemoryUsage; } catch(ErrorReport & report) {Leave(); throw report;} catch(...) {Leave(); throw(-1);} Leave(); }
void IesireDinWait6() { if(GetNrX()==0) { sleep(1); test("Verifica3",Verifica(1,0,2,0,1,0)==0); IncNrX(); Wait(m,0); IesireDinWait6(); return; } if(GetNrX()==1) { sleep(1); test("Verifica4",Verifica(1,0,1,1,2,0)==0); IncNrX(); Broadcast(m,0); sleep(1); test("Verifica5",Verifica(1,0,3,2,0,0)==0); Leave(m); return; } if(GetNrX()==2) { sleep(1); test("Verifica6",Verifica(1,0,2,2,0,0)==0); IncNrX(); Leave(m); return; } if(GetNrX()==3) { sleep(1); test("Verifica7",Verifica(1,0,1,3,0,0)==0); IncNrX(); Leave(m); return; } if(GetNrX()==4) { sleep(1); test("Verifica8",Verifica(1,0,0,4,0,0)==0); IncNrX(); Leave(m); return; } }
void udfFinalMarks::UpdateMarks() { Enter(); int nRow = 0; for(nRow = 0; nRow < m_gridMarks->GetNumberRows(); ++nRow) { int nCol = 0; for(nCol = 0; nCol < m_gridMarks->GetNumberCols(); ++nCol) { unsigned int id = -1; CChampionshipJudgesMarkTable::tDATA data = {0}; data.tourId = m_tourId; data.teamId = m_row2id[nRow]; data.judgeId = m_col2id[nCol]; long found = CChampionshipJudgesMarkTable(m_pCon).FindId(id, data); __info("Row: %d, Col: %d, tourId: %d, teamId: %d, FOUND: %d == %d", nRow, nCol, data.tourId, data.teamId, found, UDF_E_NOTFOUND); if(UDF_OK == found) { __info("Found! ID: %d. Update it...", id); m_gridMarks->GetCellValue(nRow, nCol).ToULong((unsigned long *)&data.nMark); CChampionshipJudgesMarkTable(m_pCon).UpdateRow(id, data); } else if(found == UDF_E_NOTFOUND) { __info("NOT Found! Insert it..."); m_gridMarks->GetCellValue(nRow, nCol).ToULong((unsigned long *)&data.nMark); CChampionshipJudgesMarkTable(m_pCon).AddRow(data); } } } Leave(); }
void RecursiveEdgeVisitor::VisitCrossThreadPersistent( CrossThreadPersistent* e) { AtCrossThreadPersistent(e); Enter(e); e->ptr()->Accept(this); Leave(); }
/** Delete pItem from the linked list. If bDeleteItem is VTRUE, delete will be called on pItem.*/ virtual VBOOL Delete( VLinkedListItem* pItem, VBOOL bDeleteItem = VTRUE) { Enter(); VLinkedListManager::Delete(pItem, bDeleteItem); Leave(); }
/** Adds an item to the end of the linked list unless bAddAtBeginningOfList is VTRUE.*/ virtual void Add( VLinkedListItem* pItem, VBOOL bAddAtBeginningOfList = VFALSE) { Enter(); VLinkedListManager::Add(pItem, bAddAtBeginningOfList); Leave(); }
/// @brief Performs upkeep logic /// @param bPressed If true, there is a press void Widget::Upkeep (bool bPressed) { IssueEvent(ePreUpkeep); // Perform leave logic. Leave(); // If the widget is signaled, perform enter logic; on a press, perform grab logic. if (IsSignaled()) { Enter(); if (bPressed) Grab(); } // If there is no press, perform drop logic. if (!bPressed) Drop(); // If the widget remains chosen, post-process it; otherwise, abandon it. if (!IsSignaled() && !IsChosen()) { mState->ClearChoice(); IssueEvent(eAbandon); } else IssueEvent(ePostUpkeep); }
/** * @brief Retrieves the amount of memory in use by this object. * * @return the amount of memory in use by this object. */ size_t MemoryUsageLog::GetMemorySize() const { Enter(); size_t returnMe = this->memoryUsage; Leave(); return returnMe; }
static int SimpleVolumeSet(audio_output_t *aout, float vol, bool mute) { aout_sys_t *sys = aout->sys; HRESULT hr; if (vol > 1.) vol = 1.; Enter(); /* NOTE: better change volume while muted (if mute is toggled) */ if (mute) { hr = ISimpleAudioVolume_SetMute(sys->volume.simple, true, NULL); if (FAILED(hr)) msg_Warn(aout, "cannot mute session (error 0x%lx)", hr); } hr = ISimpleAudioVolume_SetMasterVolume(sys->volume.simple, vol, NULL); if (FAILED(hr)) msg_Warn(aout, "cannot set session volume (error 0x%lx)", hr); if (mute) { hr = ISimpleAudioVolume_SetMute(sys->volume.simple, false, NULL); if (FAILED(hr)) msg_Warn(aout, "cannot unmute session (error 0x%lx)", hr); } Leave(); return 0; }
// Set IME open state void CImeView::SetState(BOOL fOpen) { if (Enter()) { ImmSetOpenStatus(m_hIMC, fOpen); Leave(); } }
Game::Game(shared_ptr<IView> _view) : userInterface(std::move(_view)) { Q_ASSERT(userInterface); players.push_back(std::make_unique<Player>("Player 1")); players.push_back(std::make_unique<Player>("Player 2")); auto v = userInterface.get(); // connect View to Presenter connect(v, SIGNAL(New_game(int)), this, SLOT(new_game(int))); connect(v, SIGNAL(Save_game(std::string)), this, SLOT(save_game(std::string))); connect(v, SIGNAL(Load_game(std::string)), this, SLOT(load_game(std::string))); connect(v, SIGNAL(Host_game(std::string)), this, SLOT(host_game(std::string))); connect(v, SIGNAL(Join_game(std::string)), this, SLOT(join_game(std::string))); connect(v, SIGNAL(Leave()), this, SLOT(leave())); connect(v, SIGNAL(Put_stone(int,int)), this, SLOT(put_stone(int,int))); connect(v, SIGNAL(Rotate(IView::quadrant,IView::turn)), this, SLOT(rotate(IView::quadrant,IView::turn))); // connect Presenter to View connect(this, SIGNAL(draw_stone(int,int,IView::color)),v,SLOT(Draw_stone(int,int,IView::color))); connect(this, SIGNAL(set_control_settings(IView::control_setting)),v,SLOT(Set_control_settings(IView::control_setting))); connect(this, SIGNAL(message(string)), v, SLOT(Show_message(string))); }
DWORD XCriticalSection::Exit() { if (m_isDestroyed) { CLog::Log(LOGWARNING, "CRITSEC[%p]: Trying to exit destroyed section.", (void *)this); return 0; } if (!m_isInitialized) { CLog::Log(LOGWARNING, "CRITSEC[%p]: Trying to exit uninitialized section.", (void *)this); return 0; } // Only an owning thread can get out of a critical section. if (!Owning()) return 0; pthread_mutex_lock(&m_countMutex); // As many times as we've entered, leave. DWORD count = m_count; for (DWORD i=0; i<count; i++) Leave(); pthread_mutex_unlock(&m_countMutex); return count; }
void RoomHandler::HandleNickConflict () { // The room is already joined, should do nothing special here. if (!Nick2Entry_.isEmpty ()) return; if (QMessageBox::question (0, tr ("Nickname conflict"), tr ("You have specified a nickname for the conference " "%1 that's already used. Would you like to try to " "join with another nick?") .arg (RoomJID_), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) { Leave (QString ()); return; } const QString& newNick = QInputDialog::getText (0, tr ("Enter new nick"), tr ("Enter new nick for joining the conference %1 (%2 is already used):") .arg (RoomJID_) .arg (OurNick_), QLineEdit::Normal, OurNick_); if (newNick.isEmpty ()) return; OurNick_ = newNick; Account_->GetClientConnection ()->GetMUCManager ()->joinRoom (RoomJID_, OurNick_); }
void SessionImpl::OnJoinSessionReply(const JoinSessionReply& reply, const NetworkConnectionPtr&) { XTASSERT(m_curState == MachineSessionState::JOINING); if (reply.GetResult()) { LogInfo("Session Join Succeeded"); SetState(MachineSessionState::JOINED); // Add the connection to the session to the Sync manager m_context->GetSyncManager()->AddConnection(m_sessionConnection); m_context->GetInternalSyncManager()->AddConnection(m_sessionConnection); // Connect the tunnel between the secondary client and the session m_tunnelBridge = new TunnelBridge(m_sessionConnection, m_context->GetPairedConnection()); AddUser(m_context->GetLocalUser()); m_sessionMgr->NotifyOnUserJoinedSessionListeners(this, m_context->GetLocalUser()); // Tell all listeners that we've successfully created the session. m_listenerList->NotifyListeners(&SessionListener::OnJoinSucceeded); } else { LogInfo("Session Join Failed!"); Leave(); } }
int User::LeaveIfError(int error) { if (OpStatus::IsError(error)) Leave(error); return error; }
// IMN_SETOPENSTATUS: BOOL CImeView::SetOpenStatus() { if (!Enter()) return FALSE; if (ImmGetOpenStatus(m_hIMC)) { // the IME conversion engine is open } else { // Here we close and destroy all of candidate windows // if IME conversion engine is closed. for (int i = 0; i < MAX_LISTCAND; i++ ) { if (m_CandList[i]) { ::DestroyWindow(m_hwndCand[i]); m_hwndCand[i] = NULL; delete m_CandList[i]; m_CandList[i] = NULL; } } m_nCompLen = 0; m_nState = 0; } Leave(); return TRUE; }
int CImeView::GetCompCursorPos() { if (!Enter()) return 0; int ret = LOWORD(ImmGetCompositionString(m_hIMC, GCS_CURSORPOS, NULL, 0)); Leave(); return ret; }
status_t GlutGameMode::Enter() { display_mode* mode = _FindMatchingMode(); if (!mode) return B_BAD_VALUE; BScreen screen; if (!fActive) { // First enter: remember this workspace original mode... fGameModeWorkspace = current_workspace(); screen.GetMode(fGameModeWorkspace, &fOriginalMode); } // Don't make it new default mode for this workspace... status_t status = screen.SetMode(fGameModeWorkspace, mode, false); if (status != B_OK) return status; // Retrieve the new active display mode, which could be // a sligth different than the one we asked for... screen.GetMode(fGameModeWorkspace, &fCurrentMode); if (!fGameModeWindow) { // create a new window fPreviousWindow = glutGetWindow(); fGameModeWindow = glutCreateWindow("glutGameMode"); if (!fGameModeWindow) return Leave(); } else // make sure it's the current window glutSetWindow(fGameModeWindow); BDirectWindow *directWindow = dynamic_cast<BDirectWindow*>(gState.currentWindow->Window()); if (directWindow == NULL) // Hum?! return B_ERROR; // Give it some useless title, except for debugging (thread name). BString name; name << "Game Mode " << fCurrentMode.virtual_width << "x" << fCurrentMode.virtual_height << ":" << _GetModePixelDepth(&fCurrentMode) << "@" << _GetModeRefreshRate(&fCurrentMode); // force the game mode window to fullscreen directWindow->Lock(); directWindow->SetTitle(name.String()); directWindow->SetFullScreen(true); directWindow->Unlock(); fDisplayChanged = true; fActive = true; return B_OK; }
//! updates the visitor void ColorVisitor::Update() { if(!m_bActive) { return; } if(m_fInterpolator < 1.0f) { Color color = Math::Lerp(m_SrcColor, m_DestColor, m_fInterpolator); UpdateColor(color); m_fInterpolator += (g_fDeltaTime/m_fDuration); } else { UpdateColor(m_DestColor); m_iPlayCount++; switch(m_ePlaybackType) { case PT_Once: Leave(); break; case PT_Loop: case PT_Toggle: if((m_iMaxPlayCount < 0) || (m_iPlayCount < m_iMaxPlayCount)) { (m_ePlaybackType == PT_Toggle) ? Math::Swap(m_SrcColor, m_DestColor) : void(); m_fInterpolator = 0.0f; } else { Leave(); } break; default: Leave(); } } }
void IesireDinSignal4() { if(GetNrX()==4) { sleep(1); test("Verifica6",Verifica(1,1,0,4,0,0)==0); IncNrX(); Leave(m); return; } if(GetNrX()==5) { sleep(1); test("Verifica7",Verifica(1,0,0,5,0,0)==0); IncNrX(); Leave(m); return; } }
//! updates the visitor void Translation3DVisitor::Update() { if(!m_bActive) { return; } if(m_fCurrentTime < m_fDuration) { Vector3 pos = Math::Lerp(m_vSrcPos, m_vDestPos, m_fCurrentTime/m_fDuration); m_p3DEntity->SetPosition(pos); m_fCurrentTime += g_fDeltaTime; } else { m_p3DEntity->SetPosition(m_vDestPos); m_iPlayCount++; switch(m_ePlaybackType) { case PT_Once: Leave(); break; case PT_Loop: case PT_Toggle: if((m_iMaxPlayCount < 0) || (m_iPlayCount < m_iMaxPlayCount)) { (m_ePlaybackType == PT_Toggle) ? Math::Swap(m_vSrcPos, m_vDestPos) : void(); m_fCurrentTime = 0.0f; } else { Leave(); } break; default: Leave(); } } }
CImeView::SetCompositionFont(LPLOGFONT lf) { BOOL ret; if (Enter()) { ret = ImmSetCompositionFont(m_hIMC, lf); Leave(); } else ret = FALSE; return ret; }
/** * @brief Retrieves the new memory size after an decrease, without * actually changing the memory size. * * @param amount The amount to decrease by. * * @return the new memory size after decrease. */ size_t MemoryUsageLog::GetNewMemorySizeAfterDecrease( size_t amount ) const { size_t returnMe; Enter(); returnMe = GetMemorySize() - amount; Leave(); return returnMe; }
void Test1()//micro { m=Create(1,SIGNAL_AND_WAIT); test("Create",m!=NULL); test("Enter",Enter(m)==0); test("Enter",Enter(m)==-1); test("Leave",Leave(m)==0); test("Leave",Leave(m)==-1); test("Wait",Wait(m,2)==-1); test("Signal",Signal(m,2)==-1); test("Broadcast",Broadcast(m,3)==-1); test("Enter",Enter(m)==0); test("Distroy", Destroy(m)==-1); test("Leave",Leave(m)==0); test("Destroy",Destroy(m)==0); }
void Individual(struct threadinfo* tinfo){ enum gender g = tinfo->g; int arrival = tinfo->arrival; int stay = tinfo->stay; int count = tinfo->count; struct timeval tv; struct timezone tz; int minqueue = 0; int avgqueue = 0; int maxqueue = 0; int i; for(i = 0; i<(count); i++){ double a = drand48(); double b = drand48(); double y = sqrt(-2 * log(a)) * cos(2 * M_PI * b); int sleepfor = arrival*y + arrival; if(sleepfor < 0) sleepfor = 0; usleep(sleepfor); gettimeofday(&tv, &tz); long prequeue = tv.tv_usec + tv.tv_sec; Enter(g); gettimeofday(&tv, &tz); long postqueue = tv.tv_usec + tv.tv_sec; long queuetime = postqueue - prequeue; if(queuetime < 0) queuetime = 0; if(minqueue == 0) minqueue = queuetime; if(queuetime < minqueue) minqueue = queuetime; if(queuetime > maxqueue) maxqueue = queuetime; avgqueue = (avgqueue*i + queuetime)/(i+1); a = drand48(); b = drand48(); y = sqrt(-2 * log(a)) * cos(2 * M_PI * b); sleepfor = stay*y + stay; if(sleepfor < 0) sleepfor = 0; usleep(sleepfor); Leave(); } printf("Thread number: %lu \n", (unsigned long)pthread_self()); printf("Gender: "); if(g == male) printf("Male \n"); else printf("Female \n"); printf("Number of loops: %d \n", count); printf("Minimum time spent in queue: %d \n", minqueue); printf("Average time spent in queue: %d \n", avgqueue); printf("Maximum time spent in queue: %d \n", maxqueue); }
void LFGMgr::Leave(Group* group) { if (!group) return; Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid()); if (!leader) return; Leave(leader); }
BOOL CImeView::GetCompString(LONG flag) { DWORD len; // Stogare for len. of composition str LPSTR str; // Pointer to composition str. LPSTR strAttr; // Pointer to composition str array. DWORD lenAttr; if (!Enter()) return FALSE; if ((len = ImmGetCompositionString(m_hIMC, GCS_COMPSTR, NULL, 0)) > 0) { str = new char[len+1]; ImmGetCompositionString(m_hIMC, GCS_COMPSTR, str, len); str[len] = 0; strAttr = NULL; if (flag & GCS_COMPATTR) { if ((lenAttr = ImmGetCompositionString(m_hIMC, GCS_COMPATTR, NULL, 0)) > 0) { strAttr = new char[lenAttr+1]; ImmGetCompositionString(m_hIMC, GCS_COMPATTR, strAttr, lenAttr); strAttr[lenAttr] = 0; } } // Override function ProcessCompString(str, strAttr); m_nCompLen = (UINT)len; if (strAttr) delete strAttr; if (str) delete str; } Leave(); return TRUE; }