Giter Site home page Giter Site logo

Comments (5)

elinorbgr avatar elinorbgr commented on June 5, 2024

Indeed, serials should "only" be locally monotonically increasing.

Probably we should add a Serial abstraction that takes the wrapping around into account correctly.

from smithay.

 avatar commented on June 5, 2024

the default serial counter which is said to wrap around on overflow

I'd also add that next_serial() returns a u32 even when usize has 64 bits, so the wrap-around (generated serial is smaller than the previous one) may happen even before that.

Is it reasonable to assume that at most u32::MAX serials have been generated between the ones being compared? If so, it could be solved storing a bool that toggles when the wrap-around happens. Then, if two serials are compared and that flag is different, we can just invert the comparison (e.g. s1 <= s2 instead of s1 > s2.) Because at most u32::MAX serials were generated, the inverted condition should hold.

from smithay.

elinorbgr avatar elinorbgr commented on June 5, 2024

I had in mind making an implementation of a serial counting taking wrap-around into account based on the fact that serials are overall quite short-lived. So even though a long-lived compositor may wrap-around the u32 in the serials it generates, the actual set of "live" serials should be much closer to each other than that.

So my idea was that if the distance between the two serials is greater than u32::MAX / 2, then assume that a wrap-around occurred between the two.

So, making a Serial(u32) type, with a custom PartialOrd impl taking that into account.

from smithay.

 avatar commented on June 5, 2024

Fair enough. I've made a pull request to do that: #230

It's my first time using git to contribute to someone else's project, so please let me know if I screwed up.

from smithay.

elinorbgr avatar elinorbgr commented on June 5, 2024

Fixed in #230

from smithay.

Related Issues (20)

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.