Skip to content

Commit

Permalink
native_layer: Draw the rest of the owl
Browse files Browse the repository at this point in the history
  • Loading branch information
dflemstr committed Oct 31, 2024
1 parent 23ed89a commit 9a4c8b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 12 additions & 3 deletions crates/layer/src/native_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use crate::{debug_annotations, error, ffi_utils, flavor, ids, init};
/// system-level events.
#[derive(Clone)]
#[repr(transparent)]
pub struct NativeLayer<W> {
pub struct NativeLayer<W>
where
W: for<'w> fmt::MakeWriter<'w>,
{
inner: sync::Arc<Inner<W>>,
}

Expand All @@ -43,7 +46,10 @@ struct ThreadLocalCtx {
descriptor_sent: atomic::AtomicBool,
}

struct Inner<W> {
struct Inner<W>
where
W: for<'w> fmt::MakeWriter<'w>,
{
// Mutex is held during start, stop, flush, and poll
ffi_session: sync::Arc<sync::Mutex<Option<cxx::UniquePtr<ffi::PerfettoTracingSession>>>>,
writer: sync::Arc<W>,
Expand Down Expand Up @@ -761,7 +767,10 @@ where
}
}

impl<W> Drop for Inner<W> {
impl<W> Drop for Inner<W>
where
W: for<'w> fmt::MakeWriter<'w>,
{
fn drop(&mut self) {
let _ = self.flush(self.drop_flush_timeout, self.drop_poll_timeout);
let _ = self.stop();
Expand Down
5 changes: 4 additions & 1 deletion crates/layer/tests/kitchen_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ data_sources:
time::sleep(time::Duration::from_secs(1)).await;

drop(enter);
perfetto_layer.flush(time::Duration::from_millis(1000))?;
perfetto_layer.flush(
time::Duration::from_millis(1000),
time::Duration::from_millis(1000),
)?;
drop(demo_span);
drop(guard);
perfetto_layer.stop()?;
Expand Down

0 comments on commit 9a4c8b8

Please sign in to comment.