Skip to content

Commit

Permalink
add ContextId
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Aug 20, 2023
1 parent f74b700 commit 0cc8393
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ pub struct RenderInfo<'a> {
pub queue: &'a wgpu::Queue,
}

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub(crate) struct ContextId {
pub id: u64
}

/// The Context stores all UI state. A user of the library
/// shouldn't have to interact with it directly.
pub struct Context {
Expand Down Expand Up @@ -127,7 +132,7 @@ thread_local! {
pub(crate) static CONTEXT: RefCell<Context> = RefCell::new(Context::new());
}

pub(crate) fn with_context<T>(f: impl FnOnce(&mut Context) -> T) -> T {
pub(crate) fn with_context<T>(id: ContextId, f: impl FnOnce(&mut Context) -> T) -> T {
CONTEXT.with(|cx| f(&mut cx.borrow_mut()))
}

Expand Down

0 comments on commit 0cc8393

Please sign in to comment.