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

Avoid using lock unnecessarily #784

Merged
merged 2 commits into from
Dec 6, 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: 4 additions & 5 deletions ddtelemetry/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ impl TelemetryWorker {
payloads.push(data::Payload::MessageBatch(obsevability_events));
}

let self_arc = Arc::new(tokio::sync::RwLock::new(self));
let self_arc = Arc::new(tokio::sync::RwLock::new(&mut *self));
let futures = payloads.into_iter().map(|payload| {
let self_arc = self_arc.clone();
async move {
Expand All @@ -454,10 +454,9 @@ impl TelemetryWorker {
});
future::join_all(futures).await;

let mut self_lock = self_arc.write().await;
self_lock.data.started = false;
if !self_lock.config.restartable {
self_lock.deadlines.clear_pending();
self.data.started = false;
if !self.config.restartable {
self.deadlines.clear_pending();
}

return BREAK;
Expand Down
Loading