To reduce code size and compilation times, it would be nice to extract its internals to a non-template implementation class. All existing code will continue using Seqlock<T>, however its methods will mostly just invoke similar methods of SeqlockImpl and make some type casts. This way, the template part will be small, and non-template part will be compiled once and reused.
We did a very similar job for core::MpscQueue here:
580
593
Unlike MpscQueue, Seqlock has state that depends on template argument (T val_), and can't be moved to implementation class.
However, it does not actually use val_ except doing a byte copy (copy constructor is not used). We can keep val_ field in template class and pass pointer to val_ as void* to methods of the implementation class. We'll also need to pass sizeof(val_) to them.
core::Seqlock<T>
template implements typed sequence lock primitive.To reduce code size and compilation times, it would be nice to extract its internals to a non-template implementation class. All existing code will continue using
Seqlock<T>
, however its methods will mostly just invoke similar methods ofSeqlockImpl
and make some type casts. This way, the template part will be small, and non-template part will be compiled once and reused.We did a very similar job for core::MpscQueue here:
580
593
Unlike MpscQueue, Seqlock has state that depends on template argument (
T val_
), and can't be moved to implementation class.However, it does not actually use
val_
except doing a byte copy (copy constructor is not used). We can keepval_
field in template class and pass pointer toval_
asvoid*
to methods of the implementation class. We'll also need to passsizeof(val_)
to them.