Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Generalize sequence incrementing and only increment sequences when time doesn't move forwards #136

Closed
wants to merge 4 commits into from

Conversation

radix
Copy link
Contributor

@radix radix commented Feb 5, 2018

This is a big backwards-incompatible change, and WORK-IN-PROGRESS.

  • UuidV1Context was renamed to DefaultUuidV1Context
  • a new trait called UuidV1Context is added. This trait has a method for getting a u16 sequence number given the current time.
  • DefaultUuidV1Context now has a Mutex in it for storing and updating the last time that a sequence number was requested. This means that DefaultUuidV1Context is only available when the std feature is enabled.

Is there any way we can avoid the context? I'm sure it probably slows down new_v1 a lot (though I plan on adding some benchmarks for this).

Also, while #106 proposed changing UuidV1Context to a trait, I think this might be unnecessary churn. A trait is a good idea, but it should probably be called something else so that UuidV1Context can remain backwards compatible.

- Rename `UuidV1Context` to `DefaultUuidV1Context`
- add a `UuidV1Context` trait that has a `generate` method that accepts
  the current time
- Store the last generated time in `DefaultUuidV1Context`

Still not actually considering the previous/current times, though.
It's actually not as bad as I expected: the new mutex-using context takes roughly twice as much time to generate a Uuid compared to the old context which only used a single AtomicUsize and always incremented it.
@kinggoesgaming
Copy link
Member

This means that DefaultUuidV1Context is only available when the std feature is enabled.

I think we need to think this one through a little more, there should be an option available when a user is in no_std mode.

@radix
Copy link
Contributor Author

radix commented Feb 6, 2018

@kinggoesgaming I have some other discussion points back on the ticket at #106.

@kinggoesgaming kinggoesgaming changed the title WIP: Generalize sequence incrementing and only increment sequences when time doesn't move forwards (wip for master branch freeze) Generalize sequence incrementing and only increment sequences when time doesn't move forwards Feb 6, 2018
@kinggoesgaming kinggoesgaming changed the title (wip for master branch freeze) Generalize sequence incrementing and only increment sequences when time doesn't move forwards (wip for master branch freeze) WIP: Generalize sequence incrementing and only increment sequences when time doesn't move forwards Feb 6, 2018
@radix radix closed this Feb 8, 2018
@kinggoesgaming
Copy link
Member

superseded by #137

@Dylan-DPC-zz Dylan-DPC-zz deleted the 106-sequence-incr branch February 8, 2018 19:55
@Dylan-DPC-zz Dylan-DPC-zz changed the title (wip for master branch freeze) WIP: Generalize sequence incrementing and only increment sequences when time doesn't move forwards WIP: Generalize sequence incrementing and only increment sequences when time doesn't move forwards Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants