rafx_framework/render_features/jobs/
job_context.rs

1use crate::render_features::render_features_prelude::*;
2
3/// A `JobContext` is definable by each `RenderFeature`. It is used to bundle any expensive
4/// work, like acquiring locks or other resources, into fewer call-sites for any work occurring on
5/// the same thread. The `JobContext` will **not** be shared between threads.
6
7/// Use `DefaultJobContext` if the `RenderFeature` does not need to acquire resources.
8pub struct DefaultJobContext {}
9
10impl DefaultJobContext {
11    /// Returns `{}`.
12    pub fn new() -> Self {
13        Self {}
14    }
15}
16
17/// Use `RenderObjectsJobContext` if the `RenderFeature` only needs to lock a `RenderObjectsMap`.
18pub struct RenderObjectsJobContext<'job, RenderObjectStaticDataT> {
19    pub render_objects: RwLockReadGuard<'job, RenderObjectsMap<RenderObjectStaticDataT>>,
20}
21
22impl<'job, RenderObjectStaticDataT> RenderObjectsJobContext<'job, RenderObjectStaticDataT> {
23    pub fn new(
24        render_objects: RwLockReadGuard<'job, RenderObjectsMap<RenderObjectStaticDataT>>
25    ) -> Self {
26        RenderObjectsJobContext { render_objects }
27    }
28}