void ShutdownThreadPool() { if (m_workerThreadPool != null) { m_workerThreadPool.FinalizeAsyncUpdateThreads(); m_workerThreadPool = null; } }
void InitializeThreadPool() { if (WorkerThreads <= 0) { WorkerThreads = Mathf.Max(Environment.ProcessorCount / 2, 1); // half of CPU threads; non-busy idle } m_workerThreadPool = new AmplifyMotion.WorkerThreadPool(); m_workerThreadPool.InitializeAsyncUpdateThreads(WorkerThreads, SystemThreadPool); }
void OnDisable() { if (m_currentPostProcess != null) { m_currentPostProcess.enabled = false; } m_workerThreadPool.FinalizeAsyncUpdateThreads(); m_workerThreadPool = null; }
void OnEnable() { m_camera = GetComponent <Camera>(); if (!CheckSupport()) { enabled = false; return; } if (WorkerThreads <= 0) { WorkerThreads = Mathf.Max(Environment.ProcessorCount / 2, 1); // half of CPU threads; non-busy idle } m_workerThreadPool = new AmplifyMotion.WorkerThreadPool(); m_workerThreadPool.InitializeAsyncUpdateThreads(WorkerThreads, SystemThreadPool); m_starting = true; if (!CreateMaterials()) { Debug.LogError("[AmplifyMotion] Failed loading or compiling necessary shaders. Please try reinstalling Amplify Motion or contact [email protected]"); enabled = false; return; } if (AutoRegisterObjs) { UpdateActiveObjects(); } InitializeCameras(); UpdateRenderTextures(true); m_linkedCameras.TryGetValue(m_camera, out m_baseCamera); if (m_baseCamera == null) { Debug.LogError("[AmplifyMotion] Failed setting up Base Camera. Please contact [email protected]"); enabled = false; return; } if (m_currentPostProcess != null) { m_currentPostProcess.enabled = true; } m_qualityLevel = QualityLevel; }
private static void AsyncUpdateThread(object obj) { #if !NETFX_CORE && !UNITY_WEBGL KeyValuePair <object, int> pair = (KeyValuePair <object, int>)obj; WorkerThreadPool pool = ( WorkerThreadPool )pair.Key; int id = ( int )pair.Value; while (true) { try { pool.m_threadPoolContinueSignals[id].WaitOne(); if (pool.m_threadPoolTerminateSignal.WaitOne(0)) { break; } while (true) { AmplifyMotion.MotionState state = null; lock (pool.m_threadStateQueueLocks[id]) { if (pool.m_threadStateQueues[id].Count > 0) { state = pool.m_threadStateQueues[id].Dequeue(); } } if (state != null) { state.AsyncUpdate(); } else { break; } } } catch (System.Exception e) { if (e.GetType() != typeof(ThreadAbortException)) { Debug.LogWarning(e); } } } #endif }
private static void AsyncUpdateThread(object obj) { KeyValuePair <object, int> keyValuePair = (KeyValuePair <object, int>)obj; WorkerThreadPool workerThreadPool = (WorkerThreadPool)keyValuePair.Key; int value = keyValuePair.Value; for (;;) { try { workerThreadPool.m_threadPoolContinueSignals[value].WaitOne(); if (!workerThreadPool.m_threadPoolTerminateSignal.WaitOne(0)) { for (;;) { MotionState motionState = null; object obj2 = workerThreadPool.m_threadStateQueueLocks[value]; lock (obj2) { if (workerThreadPool.m_threadStateQueues[value].Count > 0) { motionState = workerThreadPool.m_threadStateQueues[value].Dequeue(); } } if (motionState == null) { break; } motionState.AsyncUpdate(); } continue; } } catch (Exception ex) { if (ex.GetType() != typeof(ThreadAbortException)) { Debug.LogWarning(ex); } continue; } break; } }
void OnEnable() { if (!CheckSupport()) { enabled = false; return; } if (workerThreads <= 0) { workerThreads = Mathf.Max(Environment.ProcessorCount / 2, 1); // half of CPU threads; non-busy idle } m_workerThreadPool = new AmplifyMotion.WorkerThreadPool(); m_workerThreadPool.InitializeAsyncUpdateThreads(workerThreads); m_starting = true; CreateMaterials(); if (AutoRegisterObjs) { UpdateActiveObjects(); } InitializeCameras(); UpdateRenderTextures(); m_linkedCameras.TryGetValue(this.GetComponent <Camera>(), out m_baseCamera); if (m_baseCamera == null) { Debug.LogError("[AmplifyMotion] Failed miserably during initialization. Disabling."); enabled = false; return; } if (m_currentPostProcess != null) { m_currentPostProcess.enabled = true; } m_qualityLevel = QualityLevel; }
void OnEnable() { if (!CheckSupport()) { enabled = false; return; } if (workerThreads <= 0) { workerThreads = Environment.ProcessorCount; } m_workerThreadPool = new AmplifyMotion.WorkerThreadPool(); m_workerThreadPool.InitializeAsyncUpdateThreads(workerThreads); m_starting = true; CreateMaterials(); if (AutoRegisterObjs) { UpdateActiveObjects(); } InitializeCameras(); UpdateRenderTextures(); m_linkedCameras.TryGetValue(this.GetComponent <Camera>(), out m_baseCamera); if (m_currentPostProcess != null) { m_currentPostProcess.enabled = true; } m_qualityLevel = QualityLevel; }
void ShutdownThreadPool() { if ( m_workerThreadPool != null ) { m_workerThreadPool.FinalizeAsyncUpdateThreads(); m_workerThreadPool = null; } }
void InitializeThreadPool() { if ( WorkerThreads <= 0 ) WorkerThreads = Mathf.Max( Environment.ProcessorCount / 2, 1 ); // half of CPU threads; non-busy idle m_workerThreadPool = new AmplifyMotion.WorkerThreadPool(); m_workerThreadPool.InitializeAsyncUpdateThreads( WorkerThreads, SystemThreadPool ); }
void OnDisable() { if ( m_currentPostProcess != null ) m_currentPostProcess.enabled = false; if ( m_workerThreadPool != null ) { m_workerThreadPool.FinalizeAsyncUpdateThreads(); m_workerThreadPool = null; } }
void OnEnable() { m_camera = GetComponent<Camera>(); if ( !CheckSupport() ) { enabled = false; return; } if ( WorkerThreads <= 0 ) WorkerThreads = Mathf.Max( Environment.ProcessorCount / 2, 1 ); // half of CPU threads; non-busy idle m_workerThreadPool = new AmplifyMotion.WorkerThreadPool(); m_workerThreadPool.InitializeAsyncUpdateThreads( WorkerThreads, SystemThreadPool ); m_starting = true; if ( !CreateMaterials() ) { Debug.LogError( "[AmplifyMotion] Failed loading or compiling necessary shaders. Please try reinstalling Amplify Motion or contact [email protected]" ); enabled = false; return; } if ( AutoRegisterObjs ) UpdateActiveObjects(); InitializeCameras(); UpdateRenderTextures( true ); m_linkedCameras.TryGetValue( m_camera, out m_baseCamera ); if ( m_baseCamera == null ) { Debug.LogError( "[AmplifyMotion] Failed setting up Base Camera. Please contact [email protected]" ); enabled = false; return; } if ( m_currentPostProcess != null ) m_currentPostProcess.enabled = true; m_qualityLevel = QualityLevel; }
private void InitializeThreadPool() { if (this.WorkerThreads <= 0) { this.WorkerThreads = Mathf.Max(Environment.ProcessorCount / 2, 1); } this.m_workerThreadPool = new WorkerThreadPool(); this.m_workerThreadPool.InitializeAsyncUpdateThreads(this.WorkerThreads, this.SystemThreadPool); }
private void ShutdownThreadPool() { if (this.m_workerThreadPool != null) { this.m_workerThreadPool.FinalizeAsyncUpdateThreads(); this.m_workerThreadPool = null; } }