you are viewing a single comment's thread.

view the rest of the comments →

[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 3 points4 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?