public ByteBufferAsyncProcessor(string id, int chunkSize, Processor processor) { Id = id; myProcessor = processor; ChunkSize = chunkSize; ShrinkIntervalMs = DefaultShrinkIntervalMs; myLog = Log.GetLog <ByteBufferAsyncProcessor>().GetSublogger(Id); // var otherChunk = new Chunk(chunkSize); // myChunkToFill = new Chunk(chunkSize) { Next = otherChunk }; // otherChunk.Next = myChunkToFill; Reset(chunkSize); State = StateKind.Initialized; }
private Variable VarOfKind(TypedIdent x, StateKind k) { switch (k) { case StateKind.Local: return(new LocalVariable(Token.NoToken, x)); case StateKind.Global: return(new GlobalVariable(Token.NoToken, x)); case StateKind.FormalIn: return(new Formal(Token.NoToken, x, true)); case StateKind.FormalOut: return(new Formal(Token.NoToken, x, false)); } return(null); //impossible! }
public override void SetStateKind(StateKind stateKind) { ExecutableNodesAnalysisState.SetStateKind(stateKind); base.SetStateKind(stateKind); }
public virtual void SetStateKind(StateKind stateKind) { StateKind = stateKind; }
public TimerSetup() { _state = StateKind.Normal; }
public IState GetState(StateKind stateKind) { return(_states.TryGetValue(stateKind, out var state) ? state : throw new ArgumentException("Mode is not implemented")); }
public IState this[StateKind stateKind] => GetState(stateKind);
private void DoCommand(Command command) { if (command.kind_ == Command.Kind.Start) { current_frame_ = command.frame_; user_.InformChangingFrame(current_frame_); if (avcodec_manager_.HasVideo) { DrawWhileGetting(current_frame_); } if (avcodec_manager_.HasAudio) { if (is_wave_playing_) { System.Diagnostics.Debug.Write("waveout_.Stop()"); System.Diagnostics.Debug.Write(waveout_.State.ToString()); waveout_.Stop(); is_wave_playing_ = false; } current_wave_pos_ = GetWavePos(current_frame_); } state_ = StateKind.Waiting; } else if (command.kind_ == Command.Kind.Seek) { current_frame_ = command.frame_; user_.InformChangingFrame(current_frame_); if (avcodec_manager_.HasVideo) { DrawWhileGetting(current_frame_); } if (avcodec_manager_.HasAudio) { current_wave_pos_ = GetWavePos(current_frame_); } } else if (command.kind_ == Command.Kind.Stop) { if (avcodec_manager_.HasAudio) { if (is_wave_playing_) { waveout_.Stop(); is_wave_playing_ = false; } } if (command.frame_ >= 0) // シークする { current_frame_ = command.frame_; if (avcodec_manager_.HasVideo) { DrawWhileGetting(current_frame_); } if (avcodec_manager_.HasAudio) { current_wave_pos_ = GetWavePos(current_frame_); } } user_.InformStop(); state_ = StateKind.Prepared; } else if (command.kind_ == Command.Kind.Draw) { if (avcodec_manager_.HasVideo) { DrawWhileGetting(current_frame_); } } }
private void Run() { System.Diagnostics.Debug.Write("VideoCtrl Thread Start"); while (true) { Command command = GetCommand(); if (command != null) { if (command.kind_ == Command.Kind.EndThread) { break; } else { DoCommand(command); } } switch (state_) { case StateKind.Waiting: if ((!avcodec_manager_.HasVideo || avcodec_manager_.IsPreparedVideo(current_frame_) && avcodec_manager_.IsPreparedVideo(Math.Min(current_frame_ + 2, FrameLength - 1))) && (!avcodec_manager_.HasAudio || avcodec_manager_.IsPreparedAudio(current_wave_pos_, waveout_.BufferLength * 2))) { start_tick_time_ = Environment.TickCount; start_frame_ = current_frame_; if (avcodec_manager_.HasVideo) { user_.DisplayLoad(false); BufferContainer buffer = avcodec_manager_.GetFrame(current_frame_); if (buffer != null) { drawing_thread_.Draw(buffer.Buffer); } } if (avcodec_manager_.HasAudio) { waveout_.Play(); is_wave_playing_ = true; } state_ = StateKind.Playing; } break; case StateKind.Playing: int update_frame = (int)((Environment.TickCount - start_tick_time_) * frame_per_sec_ / 1000) + start_frame_; if (update_frame > end_frame_ || JudgeStoppingPoint(update_frame)) { lock (command_queue_) { command_queue_.Add(new Command(Command.Kind.Stop)); } } if (update_frame != current_frame_) { current_frame_ = update_frame; if (avcodec_manager_.HasVideo) { if (avcodec_manager_.IsPreparedVideo(update_frame)) { RequestDraw(current_frame_); } else { avcodec_manager_.RequireSeeking(current_frame_); state_ = StateKind.Waiting; user_.DisplayLoad(true); if (avcodec_manager_.HasAudio) { waveout_.Stop(); is_wave_playing_ = false; } } } user_.InformChangingFrame(current_frame_); } break; } Thread.Sleep(1); } thread_end_event_.Set(); }
/// <summary> /// Initializes a new instance of the State class. /// </summary> /// <param name="name">The state name.</param> /// <param name="kind">The kind of state.</param> protected State(string name, StateKind kind) { this.Name = name; this.Kind = kind; }
public SaveBlock(int numVars, StateKind kind) : base(numVars, kind) { }
// ループスレッド private void Run() { System.Diagnostics.Debug.Write("WaveManager Thread Start : " + Thread.CurrentThread.ManagedThreadId); while (state_ == StateKind.Preparing) { Thread.Sleep(1); } lock (changing_state_lock_) { if (state_ == StateKind.Prepared) { state_ = StateKind.Playing; } } while (true) { System.Diagnostics.Debug.Write("Playing"); int proceeding_kind; for (int written_data_num = 0; ; ++written_data_num) { int index = written_data_num % WAVEHDR_NUM_; System.Diagnostics.Debug.Write("Wait : index = " + index + ", state = " + state_); waiting_manager_.WaitOne(index); System.Diagnostics.Debug.Write("Wake up : index = " + index + ", state = " + state_); proceeding_kind = ProceedWrite(index); if (proceeding_kind != 1) { if (proceeding_kind == 4) // 再生終了まで待つ { waiting_manager_.Set(index); // 自分自身は待つ必要がない waiting_manager_.WaitAll(); } break; } } System.Diagnostics.Debug.Write("Exit while loop in WaveManager Thread"); waiting_manager_.SetAll(); // 次回の再生にそなえて準備 lock (changing_state_lock_) { if (state_ == StateKind.Playing) { state_ = StateKind.Stopping; } } if (OnStopped != null) { for (; stopping_times_ > 0; --stopping_times_) { OnStopped(); } } if (proceeding_kind == 3) { if (OnTimeOut != null) { OnTimeOut(); } } lock (changing_state_lock_) { if (state_ == StateKind.StoppingPlaying) // 再度再生する { state_ = StateKind.Playing; } else // 終了 { is_thread_alive_ = false; state_ = StateKind.Prepared; System.Diagnostics.Debug.Write("Thread End : " + Thread.CurrentThread.ManagedThreadId); return; } } } }
public override void SetStateKind(StateKind stateKind) { CodeBlockAnalysisState.SetStateKind(stateKind); OperationBlockAnalysisState.SetStateKind(stateKind); base.SetStateKind(stateKind); }
public State(StateKind kind) => Kind = kind;
public override void SetStateKind(StateKind stateKind) { CodeBlockAnalysisState.SetStateKind(stateKind); base.SetStateKind(stateKind); }