C Concurrency in Action by Anthony Williams Errata

background image

11.05.2013

C++ Concurrency in Action by Anthony Williams - Errata

www.manning.com/williams/excerpt_errata.html

1/2

C++ Concurrency in Action: Practical
Multithreading Errata

Page 17, third code snippet

The first line has an opening parenthesis following the

[]

lambda introducer rather than an opening brace.

It should look like this:

std::thread my_thread([]({
do_something();
do_something_else();
});

Page 90, code snippet after 4th paragraph

The duration type used for printing the time taken is incorrect and won't compile. The use of

std::chrono::seconds

as the second template parameter is incorrect, and should be removed. The

output statement should say:

std::cout<<"do_something() took "
<<std::chrono::duration<double,std::chrono::seconds>(stop-start).count()
<<" seconds"<<std::endl;

Page 120, listing 5.2

The listing uses

std::milliseconds

for the timeout. The time periods are in namespace

std::chrono

, so this should be

std::chrono::milliseconds

:

std::this_thread::sleep(std::chrono::milliseconds(1));

Page 154, listing 6.2

In the definition of

push()

, the value pushed on to the queue is of course

new_value

, not

data

. The

second line should therefore read:

data_queue.push(std::move(new_valuedata));

Page 244, listing 8.2

The line indicated by the number 9 cueball is missing template parameters for

accumulate_block

. The

line should read:

accumulate_block<Iterator,T>()(block_start,last,results[num_threads-1]);

Page 246, listing 8.3

The line indicated by the number 7 cueball is missing template parameters for

accumulate_block

. The

line should read:

T last_result=accumulate_block<Iterator,T>()(block_start,last);

Page 247, code snippet

There are missing template parameters for

accumulate_block

after the

for

loop. The line should read:

background image

11.05.2013

C++ Concurrency in Action by Anthony Williams - Errata

www.manning.com/williams/excerpt_errata.html

2/2

T last_result=accumulate_block<Iterator,T>()(block_start,last);

Page 249, listing 8.4

There are missing template parameters for the direct call to

accumulate_block

on the 4th line of the

listing on this page. The line should read:

T last_result=accumulate_block<Iterator,T>()(block_start,last);

Page 265, listing 8.11

There is a test for an empty range that returns

last

. However, this function has a

void

return type, so it

should just be a plain

return

:

if(!length)
return last;

Page 282, listing 9.5

In the

while

loop that waits for the

new_lower

result to be ready, the loop condition has a spurious

!

,

which should be removed:

while(!new_lower.wait_for(std::chrono::seconds(0))==std::future_status::timeout)


Wyszukiwarka

Podobne podstrony:
Home Missions in Action by Edith H Allen
The Southern Vampire in American Popular Fiction The Master Thesis by Anthony Hudders (2010)
Ergonomics In Action
CNC Robotics Build Your Own Workshop Bot By Geoff Williams (McGraw Hill TAB Robotics 2003) 321s
Ergonomics In Action
In Transit by Lillybellis
7lbs in 7 Days by Jason Vale
(ebook) Tillich, Paul Ultimate Concern Tillich in Dialogue by D Mackenzie Brown (existential phil
Famous Five 05 Five Go Off In A Caravan By Enid Blyton
Leslie Charteris The Saint 17 The Saint In Action
The King in Yellow by Robert W Chambers
Jagged Alliance Back in Action poradnik do gry
Schiller Eric Strategic themes in action, 1991 OCR, 102p
FIDE Trainers Surveys 2012 11 29 Jovan Petronic 2012 FIDE World Youth Chess Champions in Action
What Curiosity in the Structure The Hollow Earth in Science by Duane Griffin MS Prepared for From
Yogani Samyama Cultivating Stillness in Action, Siddhis and Miracles
Once Upon a Time in China by Nashstheory

więcej podobnych podstron