mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
core: document lock ordering and usage in state module
This commit is contained in:
@@ -1058,9 +1058,10 @@ impl Session {
|
||||
if let Ok(mut state) = self.state.try_lock() {
|
||||
if let Ok(mut active) = self.active_turn.try_lock()
|
||||
&& let Some(at) = active.as_mut()
|
||||
&& let Ok(mut ts) = at.turn_state.try_lock() {
|
||||
ts.clear_pending();
|
||||
}
|
||||
&& let Ok(mut ts) = at.turn_state.try_lock()
|
||||
{
|
||||
ts.clear_pending();
|
||||
}
|
||||
if let Some(task) = state.current_task.take() {
|
||||
task.abort(TurnAbortReason::Interrupted);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
//! Session/turn state module scaffolding.
|
||||
//! Session/turn state module.
|
||||
//!
|
||||
//! This module will encapsulate all mutable state for a Codex session.
|
||||
//! It starts with lightweight placeholders to enable incremental refactors
|
||||
//! without changing behaviour.
|
||||
//! Encapsulates all mutable state for a Codex session and the currently active
|
||||
//! turn. The goal is to present lock-safe, narrow APIs so other modules never
|
||||
//! need to poke at raw mutexes or internal fields.
|
||||
//!
|
||||
//! Locking guidelines
|
||||
//! - Lock ordering: `SessionState` → `ActiveTurn` → `TurnState`.
|
||||
//! - Never hold a lock across an `.await`. Extract minimal data and drop the
|
||||
//! guard before awaiting.
|
||||
//! - Prefer helper methods on these types rather than exposing fields.
|
||||
|
||||
mod session;
|
||||
mod turn;
|
||||
|
||||
Reference in New Issue
Block a user