Namespaces
Variants
Views
Actions

Difference between revisions of "Talk:cpp/thread/unique lock/unique lock"

From cppreference.com
(Commentary on overly complicated example.)
 
Line 9: Line 9:
 
Don't get me wrong, this is nice code and a clever way to display some Fibonacci numbers but it does not illuminate the unique_lock constructor.
 
Don't get me wrong, this is nice code and a clever way to display some Fibonacci numbers but it does not illuminate the unique_lock constructor.
  
I can't find it now but a while back I commented on an example that I thought was too terse.  The reply I got was something like "examples are the minimum to show what is needed to compile". I'm advocating for something in the middle.
+
I can't find it now but a while back I commented on an example that I thought was too terse.  The reply I got was something like "examples are the minimum to show what is needed to compile". I'm advocating for something in the middle. [[User:Arbalest|Arbalest]] ([[User talk:Arbalest|talk]]) 12:42, 8 February 2014 (PST)
 +
 
 +
: I am commenting rather than changing the example since I have been a rather inactive member of the community and don't want to step on any toes. [[User:Arbalest|Arbalest]] ([[User talk:Arbalest|talk]]) 12:42, 8 February 2014 (PST)

Revision as of 12:42, 8 February 2014

Regarding the example

This example is sufficiently complicated (perhaps) to be mainly be useful to someone who does not need an example. Note that the page is about the constructor and the example is 2 screen sizes (on my monitor) in length. Where the constructor actually occurs it is further obfuscated by a using clause.

   GuardLock lock_a(a.mutex_, std::defer_lock);  // obscures the thing being demonstrated

Why do that? (There is another using clause for the mutex which does not contribute to the code) The example includes a few ostream member overrides and, really, that vector of threads where emplace_back is called with update() is nice but was it done just to have a tight loop calling join() on each?

Don't get me wrong, this is nice code and a clever way to display some Fibonacci numbers but it does not illuminate the unique_lock constructor.

I can't find it now but a while back I commented on an example that I thought was too terse. The reply I got was something like "examples are the minimum to show what is needed to compile". I'm advocating for something in the middle. Arbalest (talk) 12:42, 8 February 2014 (PST)

I am commenting rather than changing the example since I have been a rather inactive member of the community and don't want to step on any toes. Arbalest (talk) 12:42, 8 February 2014 (PST)