Skip to content

Commit

Permalink
Enable getting a Task's Tag while inside the ExecutionState (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarsko authored Feb 5, 2024
1 parent d86479b commit 34b1db4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/current.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! example, a tool that wants to check linearizability might want access to a global timestamp for
//! events, which the [`context_switches`] function provides.
use crate::runtime::execution::ExecutionState;
use crate::runtime::execution::{ExecutionState, TASK_ID_TO_TAGS};
use crate::runtime::task::clock::VectorClock;
pub use crate::runtime::task::{Tag, Taggable, TaskId};
use std::sync::Arc;
Expand Down Expand Up @@ -51,8 +51,11 @@ pub fn get_current_task() -> Option<TaskId> {
}

/// Gets the `tag` field of the specified task.
pub fn get_tag_for_task(task: TaskId) -> Option<Arc<dyn Tag>> {
ExecutionState::get_tag_for_task(task)
pub fn get_tag_for_task(task_id: TaskId) -> Option<Arc<dyn Tag>> {
TASK_ID_TO_TAGS.with(|cell| {
let map = cell.borrow();
map.get(&task_id).cloned()
})
}

/// Sets the `tag` field of the specified task.
Expand Down
4 changes: 0 additions & 4 deletions src/runtime/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,6 @@ impl ExecutionState {
ExecutionState::with(|s| s.get_tag_or_default_for_current_task())
}

pub(crate) fn get_tag_for_task(task: TaskId) -> Option<Arc<dyn Tag>> {
ExecutionState::with(|s| s.get(task).get_tag())
}

pub(crate) fn set_tag_for_task(task: TaskId, tag: Arc<dyn Tag>) -> Option<Arc<dyn Tag>> {
ExecutionState::with(|s| s.get_mut(task).set_tag(tag))
}
Expand Down

0 comments on commit 34b1db4

Please sign in to comment.