Namespaces
Variants
Views
Actions

Talk:cpp/thread/unique lock

From cppreference.com

void slow_log(bank_account &from, bank_account &to, int amount);

in void transfer(bank_account &from, bank_account &to, int amount) {

   // ...
   int from_copy = from.balance;
   int to_copy = to.balance;
   // ...
   slow_log(from_copy, to_copy, amount);

}

Types in call to slow_log do not match declaration.

Fixed. --198.228.201.150 18:40, 20 July 2012 (PDT)

Mutex and mutex_type

The template parameter "Mutex" is/was too similar to the type "mutex". It seems that "mutex_type" might have been intended anyway. The corresponding Template Parameter section was updated.

HOWEVER, the Member Types section seems a little nonsensical. Is this saying that the type is maintained as a member of the unique_lock? If so, what should be under the column heading "Definition"? A repeat of the text that goes with the template parameter? Arbalest (talk) 17:15, 11 March 2014 (PDT)

The class unique_lock exposes a type (via a public typedef) named "mutex_type", which is defined to be the same as the template argument type. I don't think it's going to work to have that template argument named "mutex_type" as well -- it'll make things way more confusing than before. I suspect the reason that we went with "Mutex" as the template argument is because that's how the standard does it. Do you have any ideas for something that works better than "Mutex"? --Nate (talk) 17:33, 11 March 2014 (PDT)
Oh, I didn't realize that mutex_type on the constructor page came from the member of that name. Arbalest (talk) 09:45, 12 March 2014 (PDT)
BasicLockable could work, except that it would make the text confusing where it talks about what unique_lock does when its template parameter is Lockable or TimedLockable. It could be just T (note that there are several more mentions of Mutex that weren't changed --Cubbi (talk) 18:06, 11 March 2014 (PDT)