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

native_layer: Add support for creating async task tracks #18

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
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
61 changes: 60 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ anyhow = "1.0.90"
bytes = "1.8.0"
cxx = { version = "1.0.129", features = ["c++17"] }
cxx-build = { version = "1.0.129", features = ["parallel"] }
dashmap = "6.1.0"
futures = "0.3.31"
nix = "0.29.0"
pbjson = "0.6.0"
Expand Down
1 change: 1 addition & 0 deletions crates/layer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition.workspace = true
[dependencies]
bytes.workspace = true
cxx.workspace = true
dashmap.workspace = true
nix = { workspace = true, features = ["time"] }
prost.workspace = true
thiserror.workspace = true
Expand Down
9 changes: 8 additions & 1 deletion crates/layer/src/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ impl TrackUuid {
TrackUuid(h.finish())
}

#[cfg(feature = "tokio")]
pub fn for_task(id: task::Id) -> TrackUuid {
let mut h = hash::DefaultHasher::new();
(TRACK_UUID_NS, TASK_NS, id).hash(&mut h);
TrackUuid(h.finish())
}

#[cfg(feature = "tokio")]
pub fn for_tokio() -> TrackUuid {
let mut h = hash::DefaultHasher::new();
Expand Down Expand Up @@ -66,7 +73,7 @@ impl SequenceId {
#[cfg(feature = "tokio")]
pub fn for_task(id: task::Id) -> SequenceId {
let mut h = hash::DefaultHasher::new();
(TRACK_UUID_NS, TASK_NS, id).hash(&mut h);
(SEQUENCE_ID_NS, TASK_NS, id).hash(&mut h);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental typo in a previous PR, but shouldn't have mattered too much as SequenceId and TrackUuid are already in separate namespaces.

SequenceId(h.finish() as u32)
}

Expand Down
Loading