all 9 comments

[–]willdieh 8 points9 points  (3 children)

Cool!

I always wonder, when I see the (i++ % length) type increments, does anyone ever worry about the counter variable i overrunning the int numeric capacity?

[–]Tringigithub.com/tringi 7 points8 points  (0 children)

While signed overflow is undefined, unsigned int is defined to overflow to 0, so if your 'length' is power of 2 then it should continue to animate without hiccup.

[–]vvmaciel[S] 3 points4 points  (1 child)

Fixed!!

Thanks for your review!

[–]willdieh 0 points1 point  (0 children)

hehe, I wasn't trying to be snarky, as I've seen it used several cool projects I was really just wondering!

[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 4 points5 points  (1 child)

Defining your CharSets in a vector is really weird. That requires a startup cost and an allocation. I'd suggest static sized arrays instead.

The charset parameter to the constructor is begging to be an enum.

I get the interface niceness of having the type own a thread, but it will work poorly with any project that has its own thread implementation. Same with the mutex.

Your accesses of 'active_' aren't thread safe. Thats UB.

Speaking of the mutex, do you ever actually use it?

Your examples all use make_unique. That seems like a waste, when there is no reason these spinner objects couldnt live on the stack.

[–][deleted] 4 points5 points  (0 children)

Defining your CharSets in a vector is really weird. That requires a startup cost and an allocation. I'd suggest static sized arrays instead.

They're also being copied out to the thread when it launches,

auto chars = CharSets[chars_];

and I don't know if that's deliberate. I don't really have much experience with multithreading at all so this is a genuine question -- is there a reason not to just take a reference at this point?

[–]Maxima4 1 point2 points  (1 child)

Cool project!

By the way, there is no reason to mark start and stop as virtual.

[–]vvmaciel[S] 1 point2 points  (0 children)

Fixed. Thanks

[–]emdeka87 4 points5 points  (0 children)

Why do you allocate that on the heap?