oklog / ulid

Universally Unique Lexicographically Sortable Identifier (ULID) in Go
Apache License 2.0
4.44k stars 161 forks source link

Why not make MonotonicRead thread safe? #72

Closed Scratch-net closed 2 years ago

Scratch-net commented 2 years ago

It's easy to wrap it into a lock, isn't it? Or at least add such an option if speed is an issue. I could make a PR if it's ok with you

peterbourgon commented 2 years ago

It's a speed consideration for sure. We expect users to be able to add synchronization if it's important. But a PR that adds a goroutine-safe option may be cool. What's your plan?

peterbourgon commented 2 years ago

Feel free to reopen with details.

frederikhors commented 2 years ago

Wow.

This is a big problem if there are inexperienced but passionate people like me.

@peterbourgon, can I ask you for an example code to be safe when using ulid with various goroutines?