Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable getting a Task's Tag while inside the ExecutionState #132

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/current.rs
Original file line number Diff line number Diff line change
@@ -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;
@@ -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.
4 changes: 0 additions & 4 deletions src/runtime/execution.rs
Original file line number Diff line number Diff line change
@@ -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))
}