Skip to main content

Timeline for Win7 atomic access class

Current License: CC BY-SA 3.0

9 events
when toggle format what by license comment
Jun 9, 2012 at 11:19 comment added Corbin @KonradRudolph Ah ok, thanks. I thought it would silently do: type x; x.operator=(...); Did not realize it would do type x(...);. Been a while since I've done anything more than a few lines of C++ :).
Jun 9, 2012 at 11:09 comment added Konrad Rudolph @Corbin it is, but type x = … would invoke copy construction, never copy assignment. But it’s always optimised anyway so that no copy is made, ever. But note that the copy constructor needs to be available anyway.
Jun 8, 2012 at 22:51 comment added Corbin @JakubZaverka "The assignment operator works for me, if I declare it as a class field and assign a value in the constructor." It works for now. But when you clobber one of the CRITICAL_SECTIONs with a different CRITICAL_SEECTION all kinds of weird bugs can happen later.
Jun 8, 2012 at 22:46 comment added Corbin @KonradRudolph That explains it then. I had always thought that converting type x = ...; to type x (...) was an optional optimization.
Jun 8, 2012 at 16:00 comment added Jakub Zaverka And I now realized I don't even have operator=(AtomicAccess), I have operator=(aa_type). (I am assigning value at initialisation and then only ++ing or --ing.)
Jun 8, 2012 at 15:48 comment added Jakub Zaverka And other remarks do not lack relevance as well. Thanks. Just one clarification: The way I intend to design it is only through typedefs. So if I typedef int_aa, then I want int_aa to behave in every way (or at least in ways I need) as a normal integer, but with synchronized access. The code using it should neved use the AtomicAccess class directly.
Jun 8, 2012 at 15:44 comment added Jakub Zaverka The assignment operator works for me, if I declare it as a class field and assign a value in the constructor. And I also don't want to copy Critical sections. They are meant only as a necessary evil and if I do the assignment from one AtomicAcess to another, then the inner value should be copied only. This is a good remark, thanks, even though I have no such assignments in the code.
Jun 8, 2012 at 9:56 comment added Konrad Rudolph Assignment operator is never invoked in an initialisation. That explains why int_aa x = 5; doesn’t work.
Jun 8, 2012 at 1:49 history answered Corbin CC BY-SA 3.0