Coder Social home page Coder Social logo

bbl-usd-rs's People

Contributors

anderslanglands avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bbl-usd-rs's Issues

Threading Model (๐Ÿ˜ฌ)

I've started to use the crate in a multithreaded way and it's proving to be a little bit of a pain. According to https://openusd.org/dev/api/_usd__page__multi_threading.html, the USD threading model is essentially the same as Rusts: multiple readers or a single writer. It should be valid to unsafe impl both Send and Sync for everything.

Currently, essentially all methods take &self, e.g.

pub fn prim_at_path<P: Into<sdf::Path>>(&self, path: P) -> Result<Prim, Error>;

This is problematic when modifying a prims attributes comes into consideration, as currently this will allow writing to the stage from two seperate threads which (usually) results in a segfault.

you could have two seperate methods for read/write vs read-only prims:

pub fn prim_at_path_<P: Into<sdf::Path>>(&self, path: P) -> Result<Prim, Error>;
pub fn prim_mut_at_path<P: Into<sdf::Path>>(&mut self, path: P) -> Result<PrimMut, Error>;

But this doesn't properly reflect the fact that both prim types are effectively borrowing the stage they exist within, meaning that you could keep a PrimMut around after the write-access to the stage has ended. Adding lifetime annotations is probably a no-go as well.

A better solution is to wrap the whole stage in an Arc'd RwLock of some kind, and clone that when accessing any prim or attribute, locking it for either read or write depending on what's being read out. Implementing this would be a massive pain though and you'd probably want two implementations for both blocking and async locks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.