bool operator < (const event &rhs) const { if (cmp() != rhs.cmp()) return cmp() < rhs.cmp(); if (start != rhs.start) return start < rhs.start; return radius > rhs.radius; }
void QtHost::SendGPUWait(u32 cmd, u32 addr, void *data) { EmuThread_LockDraw(false); if((m_GPUFlag == 1 && (cmd == GE_CMD_PRIM || cmd == GE_CMD_BEZIER || cmd == GE_CMD_SPLINE))) { // Break after the draw m_GPUFlag = 0; } else if(m_GPUFlag == 0) { mainWindow->GetDialogDisasm()->UpdateDisplayList(); mainWindow->GetDialogDisplaylist()->Update(); m_hGPUStepEvent.wait(m_hGPUStepMutex); } else if(m_GPUFlag == 2 && addr == m_GPUData) { mainWindow->GetDialogDisasm()->UpdateDisplayList(); mainWindow->GetDialogDisplaylist()->Update(); m_hGPUStepEvent.wait(m_hGPUStepMutex); } else if(m_GPUFlag == 3 && (cmd == GE_CMD_PRIM || cmd == GE_CMD_BEZIER || cmd == GE_CMD_SPLINE)) { GPUgstate *state = (GPUgstate*)data; u32 texAddr = (state->texaddr[0] & 0xFFFFF0) | ((state->texbufwidth[0]<<8) & 0x0F000000); if(texAddr == m_GPUData) { mainWindow->GetDialogDisasm()->UpdateDisplayList(); mainWindow->GetDialogDisplaylist()->Update(); m_hGPUStepEvent.wait(m_hGPUStepMutex); } } EmuThread_LockDraw(true); }
void journal::write( const event& e ) { LOG_DEBUG( l, "journal " << e.get_length() << " bytes" ); _file.seekp( 0, std::ios_base::end ); _file.write( (char*)&e.get_header(), e.get_length() ); if( !_file.good() ) { eva_exception( "failed to write to journal" ); } }
bool print(Iterator& out, event const& e) const { using namespace printers; if (e.type().name().empty() && !str.print(out, "<anonymous>")) return false; return str.print(out, e.type().name()) && str.print(out, " [") && u64.print(out, e.id()) && any.print(out, '|') && make_printer<time::point>{}.print(out, e.timestamp()) && str.print(out, "] ") && make_printer<value>{}.print(out, e); }
bool checkbox_w::mouse_move( const event &e ) { if ( _tracking ) { if ( contains( e.from_native( e.raw_mouse().x, e.raw_mouse().y ) ) ) _current = !_state; else _current = _state; invalidate(); return true; } return false; }
std::vector<fsw_event_flag> monitor::filter_flags(const event& evt) const { // If there is nothing to filter, just return the original vector. if (event_type_filters.empty()) return evt.get_flags(); std::vector<fsw_event_flag> filtered_flags; for (auto const& flag : evt.get_flags()) { if (accept_event_type(flag)) filtered_flags.push_back(flag); } return filtered_flags; }
void arr_cust() { create("arr_cust"); line.reserve(); // join the line and wait to be head vendingMachineRequested.set(); // i am the front of the line waitVendingMachineOpen.queue(); // wait for an open machine vendingMachineRequested.clear(); // vending machine is open and im taking it clear for next in line vendingMachineIsOpen.set(); // tell vending machine that i am about to use it. line.release(); // i am not the head of the line anymore pass it to next in line. doneWithMachine.wait(); // I am done after time to use machine is free and im leaving and dying. // set up shuttle process }
static void print_event_flags(const event & evt) { const vector<fsw_event_flag> & flags = evt.get_flags(); if (nflag) { int mask = 0; for (const fsw_event_flag &flag : flags) { mask += static_cast<int> (flag); } cout << mask; } else { for (size_t i = 0; i < flags.size(); ++i) { cout << flags[i]; // Event flag separator is currently hard-coded. if (i != flags.size() - 1) cout << event_flag_separator; } } }
std::string to_string (const event & ev) { std::string result("event: "); midibyte d0, d1; ev.get_data(d0, d1); char temp[128]; snprintf ( temp, sizeof temp, "[%04lu] status = 0x%02X; channel = 0x%02X; data = [0x%02X, 0x%02X]\n", ev.get_timestamp(), ev.get_status(), ev.get_channel(), d0, d1 ); result += std::string(temp); return result; }
void Core_EnableStepping(bool step) { if (step) { //PowerPC::Pause(); // Sleep(1); sleep_ms(1); #if _DEBUG host->SetDebugMode(true); #endif coreState=CORE_STEPPING; } else { #if _DEBUG host->SetDebugMode(false); #endif coreState = CORE_RUNNING; //PowerPC::Start(); ///SetEvent(m_hStepEvent); //TODO: pulseevent is flawed and can be lost m_hStepEvent.notify_one(); } }
void Core_EnableStepping(bool step) { if (step) { sleep_ms(1); #if defined(_DEBUG) host->SetDebugMode(true); #endif m_hStepEvent.reset(); Core_UpdateState(CORE_STEPPING); } else { #if defined(_DEBUG) host->SetDebugMode(false); #endif coreState = CORE_RUNNING; coreStatePending = false; m_hStepEvent.notify_one(); } }
bool event::operator < (const event & rhs) const { if (m_timestamp == rhs.m_timestamp) return get_rank() < rhs.get_rank(); else return m_timestamp < rhs.m_timestamp; }
void QtHost::SendGPUWait() { EmuThread_LockDraw(false); mainWindow->GetDialogDisasm()->UpdateDisplayList(); m_hGPUStepEvent.wait(m_hGPUStepMutex); EmuThread_LockDraw(true); }
bool checkbox_w::mouse_release( const event &e ) { if ( e.raw_mouse().button != 1 ) return false; if ( _tracking ) { _tracking = false; if ( contains( e.from_native( e.raw_mouse().x, e.raw_mouse().y ) ) ) set_state( _current ); _current = _state; invalidate(); context::current().release_source( e ); return true; } return false; }
void manageMachines(){ create("manageMachines"); double B,timeUsingMachine; while (1) { vendingMachineRequested.wait(); B = uniform(10,60); timeUsingMachine = 150 + uniform((B/2),30); waitVendingMachineOpen.set(); vendingMachineIsOpen.wait(); numberOfMachinesBeingUsed++; hold(timeUsingMachine); doneWithMachine.set(); numberOfMachinesBeingUsed--; } }
/*-------------------------------------------------------------------- * event handler * * when a event occurs, this function is invoked */ void src_viewer::handle_event( event& e ) { inherited::handle_event( e ); switch ( e.kind() ) { case SELECTION: { vnode* vn = e.get_object(); void* event_source = e.get_source(); if ( event_source == text ) return; // ignore local event show( vn ); } break; case CLOSE_FILESET: { clear_cache(); clear(); } break; case NEW_FILESET: { /* show the first file_block */ FileSetBlock* file_set = suif_env->get_file_set_block(); if (file_set) { view(file_set->get_file_block(0)); } } break; case REFRESH: case PROC_MODIFIED: case FSE_MODIFIED: { refresh(); } break; default: break; } }
bool checkbox_w::mouse_press( const event &e ) { if ( e.raw_mouse().button != 1 ) return false; context::current().grab_source( e, shared_from_this() ); _tracking = true; _current = !_state; invalidate(); return _tracking; }
void sim(int argc, char *argv[]) { set_model_name("M/M/1 Queue"); create("sim"); cnt = NARS; for(int i = 1; i <= NARS; i++) { hold(expntl(IAR_TM)); // interarrival interval customer(); // generate next customer } done.wait(); // wait for last customer to depart report(); // model report theory(); mdlstat(); // model statistics }
/*-------------------------------------------------------------------- * event handler * */ void info_viewer::handle_event( event& e ) { inherited::handle_event(e); switch (e.kind()) { case SELECTION: { if ( e.get_source() == text ) { return; // ignore local selection } view( e.get_object() ); } break; case INVOCATION: { if ( e.get_source() == text ) { /* local event */ view( e.get_object() ); } } break; case CLOSE_FILESET: case NEW_FILESET: { clear(); } break; case REFRESH: case PROC_MODIFIED: case FSE_MODIFIED: { refresh(); } break; default: break; } }
/*-------------------------------------------------------------------- * event handler * * when a event occurs, this function is invoked */ void output_viewer::handle_event(event& e) { inherited::handle_event( e ); switch ( e.kind() ) { case SELECTION: { void* event_source = e.get_source(); if (event_source == text) return; // ignore local event show( e.get_object() ); } break; case CLOSE_FILESET: { clear(); } break; default: break; } }
static void print_event_timestamp(const event & evt) { const time_t & evt_time = evt.get_time(); char time_format_buffer[TIME_FORMAT_BUFF_SIZE]; struct tm * tm_time = uflag ? gmtime(&evt_time) : localtime(&evt_time); string date = strftime(time_format_buffer, TIME_FORMAT_BUFF_SIZE, tformat.c_str(), tm_time) ? string(time_format_buffer) : string(_("<date format error>")); cout << date; }
void customer() // arriving customer { float t1; create("cust"); t1 = clock; // record start time qtbl.note_entry(); // note arrival f.reserve(); // reserve facility hold(expntl(SRV_TM)); // service interval f.release(); // release facility tbl.record(clock - t1); // record response time qtbl.note_exit(); // note departure if(--cnt == 0) done.set(); // if last customer, set done }
static void do_go_cmd(const event& e, void*) { binding *b; char *node_name; char *node_info; vmenu *menu = (vmenu *) e.get_source(); menu->clear("Go"); b = new binding((bfun) &do_go_back_cmd, 0); menu->add_command(b, "Go", "Back"); menu->add_separator("Go"); /* construct list of previously selected objects */ vnode_list *hist = vman->get_selection_history(); for ( s_count_t i=1; /* jump over current object */ (i<20) && (i<hist->size()); i++ ) { vnode *vn = (*hist)[i]; char *tag = vn->get_tag(); if ( tag == tag_suif_object ) { SuifObject *obj = (SuifObject *) vn->get_object(); node_info = (char*)obj->get_meta_class()->get_class_name().c_str(); } else if (tag == tag_code_fragment) { node_info = ""; } else { suif_assert_message( false, ("Unknown tag") ); } node_name = new char[strlen(tag)+strlen(node_info)+100 /*just to be safe*/]; sprintf(node_name, "[%s] (0x%p) %s", tag, vn->get_object(), node_info); b = new binding((bfun) &do_go_to_node_cmd, vn); menu->add_command(b, "Go", node_name); delete [] node_name; } }
// Some platforms, like Android, do not call this function but handle things on their own. void Core_Run() { #if _DEBUG host->UpdateDisassembly(); #endif while (true) { reswitch: switch(coreState) { case CORE_RUNNING: //1: enter a fast runloop Core_RunLoop(); break; // We should never get here on Android. case CORE_STEPPING: //1: wait for step command.. m_hStepEvent.wait(m_hStepMutex); if (coreState == CORE_POWERDOWN) return; if (coreState != CORE_STEPPING) goto reswitch; currentCPU = &mipsr4k; Core_SingleStep(); //4: update disasm dialog #ifdef _DEBUG host->UpdateDisassembly(); host->UpdateMemView(); #endif break; case CORE_POWERDOWN: case CORE_ERROR: //1: Exit loop!! return; } } }
void connector::on_transport_closed(event &e) { if (!connection_) return; if (connection_.state() & endpoint::LOCAL_ACTIVE) { if (reconnect_timer_) { e.connection().transport().unbind(); transport_configured_ = false; int delay = reconnect_timer_->next_delay(); if (delay >= 0) { if (delay == 0) { // log "Disconnected, reconnecting..." connect(); return; } else { // log "Disconnected, reconnecting in " << delay << " milliseconds" connection_.container().schedule(delay, this); return; } } } } connection_.release(); connection_ = 0; }
void Core_WaitInactive(int milliseconds) { if (Core_IsActive()) { m_hInactiveEvent.wait_for(m_hInactiveMutex, milliseconds); } }
void Core_WaitInactive() { while (Core_IsActive()) { m_hInactiveEvent.wait(m_hInactiveMutex); } }
static inline void CoreStateProcessed() { if (coreStatePending) { coreStatePending = false; m_hInactiveEvent.notify_one(); } }
void Core_Stop() { Core_UpdateState(CORE_POWERDOWN); Core_NotifyShutdown(); m_hStepEvent.notify_one(); }
// Some platforms, like Android, do not call this function but handle things on their own. void Core_Run() { #if defined(_DEBUG) host->UpdateDisassembly(); #endif #if !defined(USING_QT_UI) || defined(USING_GLES2) while (true) #endif { reswitch: if (globalUIState != UISTATE_INGAME) { CoreStateProcessed(); if (globalUIState == UISTATE_EXIT) { return; } Core_RunLoop(); #if defined(USING_QT_UI) && !defined(USING_GLES2) return; #else continue; #endif } switch (coreState) { case CORE_RUNNING: // enter a fast runloop Core_RunLoop(); break; // We should never get here on Android. case CORE_STEPPING: singleStepPending = false; CoreStateProcessed(); // Check if there's any pending savestate actions. SaveState::Process(); if (coreState == CORE_POWERDOWN) { return; } // wait for step command.. #if defined(USING_QT_UI) || defined(_DEBUG) host->UpdateDisassembly(); host->UpdateMemView(); host->SendCoreWait(true); #endif m_hStepEvent.wait(m_hStepMutex); #if defined(USING_QT_UI) || defined(_DEBUG) host->SendCoreWait(false); #endif #if defined(USING_QT_UI) && !defined(USING_GLES2) if (coreState != CORE_STEPPING) return; #endif // No step pending? Let's go back to the wait. if (!singleStepPending || coreState != CORE_STEPPING) { if (coreState == CORE_POWERDOWN) { return; } goto reswitch; } Core_SingleStep(); // update disasm dialog #if defined(USING_QT_UI) || defined(_DEBUG) host->UpdateDisassembly(); host->UpdateMemView(); #endif break; case CORE_POWERUP: case CORE_POWERDOWN: case CORE_ERROR: // Exit loop!! CoreStateProcessed(); return; case CORE_NEXTFRAME: return; } } }