int dfs(int x, int y) { if (y == 9) { if (!safe(x-1, y-1) || !safe(x-1, y-2)) return 0; x++, y = 0; } if (x == 9) { for (int i = 0; i < 9; i++) if (!safe(8, i)) return 0; for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) printf("%d%c", ret[i][j], j == 8 ? '\n' : ' '); return 1; } if (!safe(x-1, y-2)) return 0; if (dfs(x, y+1)) return 1; int f = canplace(x, y); if (f) { _remove(x, y); if (dfs(x, y+1)) return 1; _resume(x, y); } return 0; }
void Java_com_example_SanAngeles_DemoGLSurfaceView_nativeTogglePauseResume( JNIEnv* env ) { sDemoStopped = !sDemoStopped; if (sDemoStopped) _pause(); else _resume(); }
void EmbeddedGamePanel::_onPaint(wxPaintEvent& evt) { wxPaintDC dc(this); m_pGLContext->SetCurrent(*m_pGLCanvas); if(m_L == NULL) { // Its rather hacky to be loading the Lua side of things from within // the paint handler, but Lua needs an OpenGL context to be active, and // we cannot give it one during the EmbeddedGamePanel constructor. loadLua(); } // Update the OpenGL projection matrix and Lua window size settings to keep // a 1:1 mapping between world space and screen space const wxSize szClient = GetClientSize(); glViewport(0, 0, szClient.x, szClient.y); GLdouble fWidth = (GLdouble)szClient.x; GLdouble fHeight = (GLdouble)szClient.y; THRenderTarget::setGLProjection(fWidth, fHeight); if(m_L) { lua_getglobal(m_L, "TheApp"); if(lua_isnil(m_L, -1)) lua_pop(m_L, 1); else { lua_getfield(m_L, -1, "config"); lua_pushinteger(m_L, szClient.x); lua_setfield(m_L, -2, "width"); lua_pushinteger(m_L, szClient.y); lua_setfield(m_L, -2, "height"); lua_pop(m_L, 2); } } // Do the actual painting if(m_Lthread) { lua_State *L = lua_tothread(m_Lthread, 1); if(L == NULL) { for(int i = 1; i <= lua_gettop(m_L); ++i) { wxPrintf("m_L stack %i: %s\n", i, lua_typename(m_L, lua_type(m_L, i))); } for(int i = 1; i <= lua_gettop(m_Lthread); ++i) { wxPrintf("m_Lthread stack %i: %s\n", i, lua_typename(m_Lthread, lua_type(m_Lthread, i))); } } lua_pushliteral(L, "frame"); _resume(L, 1, 0); } }
static void _run(struct coroutine *co) { _set_running_coroutine(co); _resume(co); _set_running_coroutine(NULL); if (co->status == STATUS_EXITING) { coroutine_delete(co); return; } _save_stack(co); }
int64_t CoroutinePool::resume(const int64_t id, Object* param, const int64_t sign){ if(m_cleaning){ WARN("coroutine pool resume failed, cleaning"); return -ErrorCode::SYSTEM_ERROR; } if(Coroutine* cr =static_cast< Coroutine* >(m_active_coroutine_table->get(id))){ return _resume(cr, param, sign); } else{ WARN("coroutine manager resume failed, coroutine %lld not found", (long long)id); return -ErrorCode::NOT_EXIST; } }
int64_t CoroutinePool::go(Coroutine::PFN_COROUTINE_TASK pfn, Object* arg, int64_t& cr_id){ if(m_cleaning){ WARN("coroutine pool go failed, cleaning"); return -ErrorCode::SYSTEM_ERROR; } if(!pfn){ return -ErrorCode::INVALID_ARG; } // prepare Coroutine* cr =_prepare_coroutine(pfn, arg); const int64_t result =_resume(cr, 0, 0); if(result == Coroutine::STATUS_WAITING){ cr_id =cr->getId(); } return result; }
void MovieSprite::play() { if (_playing) { if (_paused) { _resume(); _paused = false; return; } return; } _playing = true; initPlayer(); _completeDispatched = false; _play(); }
int main(int argc, char *argv[]) { void **ptrs; long num; long i; int loop; srand((unsigned int)time(NULL)); num = atol(argv[1]); ptrs = malloc(sizeof(void*) * num); for(i = 0; i < num; i++) { ptrs[i] = malloc(get_random_size()); } _reset_clock(); for(loop = 0; loop < NUM_LOOPS; loop++) { for(i = 0; i < num; i++) { if((rand() % 2) == 0) { free(ptrs[i]); ptrs[i] = NULL; } } for(i = 0; i < num; i++) { if(ptrs[i] == NULL) { _resume(); ptrs[i] = malloc(get_random_size()); _pause(); } } } _print_elapsed_time(); return 0; }
void Slower::resume() { _resume(); paused = false; }
void Java_com_example_SanAngeles_DemoGLSurfaceView_nativeResume( JNIEnv* env ) { _resume(); }
// ---------------------------------------------------------------------------- // UINT SpotifyEngine::run() { log_status( "Spotify engine started" ); int next_timeout = 0; ULONG wait_time = 0L; while ( isRunning() ) { try { while ( ::WaitForSingleObject( m_spotify_notify, 100 ) != WAIT_OBJECT_0 ) { if ( m_current_track != NULL ) { switch ( m_track_state ) { case TRACK_STREAM_COMPLETE: sp_session_player_unload( m_spotify_session ); m_track_state = TRACK_PLAYING; break; case TRACK_PLAYING: if ( m_audio_out->getCachedSamples() == 0 ) { _processTrackAnalysis(); m_track_state = TRACK_ENDED; m_current_track = NULL; wait_time = 0; m_track_timer.stop(); _startTrack(); } break; } } if ( GetCurrentTime() > wait_time ) break; } // Handle any pending user command switch ( m_spotify_command ) { case CMD_STOP_TRACK: _stopTrack(); break; case CMD_NEXT_TRACK: _stopTrack(); _startTrack(); break; case CMD_PAUSE_TRACK: _pause(); break; case CMD_RESUME_TRACK: _resume(); break; case CMD_CHECK_PLAYING: if ( m_current_track == NULL ) _startTrack(); break; } m_spotify_command = CMD_NONE; // Dispatch Spotify messages do { sp_session_process_events( m_spotify_session, &next_timeout ); } while (next_timeout == 0); if ( next_timeout != 0 ) wait_time = next_timeout + GetCurrentTime(); else wait_time = 0; } catch ( std::exception& ex ) { log( ex ); m_spotify_error = ex.what(); } } log_status( "Spotify engine stopped" ); return 0; }
/** resume **/ int64_t Coroutine::resume(Object* param){ return _resume(param); }
void Java_com_example_SanAngeles_DemoGLSurfaceView_nativeResume( JNIEnv* env ) { _resume(); // BREAKPOINT MARKING COMMENT }