Skip to content

Commit 60e3875

Browse files
Fix some typos in the concurrency section
1 parent 8e82f0a commit 60e3875

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

CppCoreGuidelines.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10253,7 +10253,7 @@ the same memory. Concurrent programming is tricky for many reasons, most
1025310253
importantly that it is undefined behavior to read data in one thread after it
1025410254
was written by another thread, if there is no proper synchronization between
1025510255
those threads. Making existing single-threaded code execute concurrently can be
10256-
as trivial as adding `std::async` or `std::thread` strategically, or it can be
10256+
as trivial as adding `std::async` or `std::thread` strategically, or it can
1025710257
necessitate a full rewrite, depending on whether the original code was written
1025810258
in a thread-friendly way.
1025910259

@@ -10432,7 +10432,7 @@ Help the tools:
1043210432
##### Reason
1043310433

1043410434
If you don't share writable data, you can't have a data race.
10435-
The less sharing you do, the less chance you have to forget to synchanize access (and get data races).
10435+
The less sharing you do, the less chance you have to forget to synchronize access (and get data races).
1043610436
The less sharing you do, the less chance you have to wait on a lock (so performance can improve).
1043710437

1043810438
##### Example
@@ -10458,7 +10458,7 @@ The less sharing you do, the less chance you have to wait on a lock (so performa
1045810458
// ...
1045910459
}
1046010460

10461-
Without those `const`s, we would have to review every asynchroneously invoked function for potential data races on `surface_readings`.
10461+
Without those `const`s, we would have to review every asynchronously invoked function for potential data races on `surface_readings`.
1046210462

1046310463
##### Note
1046410464

@@ -10474,7 +10474,7 @@ No locking is needed: You can't have a data race on a constant.
1047410474

1047510475
##### Reason
1047610476

10477-
A `thread` is a implementation concept, a way of thinking about the machine.
10477+
A `thread` is an implementation concept, a way of thinking about the machine.
1047810478
A task is an application notion, something you'd like to do, preferably concurrently with other tasks.
1047910479
Application concepts are easier to reason about.
1048010480

@@ -10565,7 +10565,7 @@ Concurrency rule summary:
1056510565
* [CP.27: Use plain `std::thread` for `thread`s that detach based on a run-time condition (only)](#Rconc-thread)
1056610566
* [CP.28: Remember to join scoped `thread`s that are not `detach()`ed](#Rconc-join)
1056710567
* [CP.30: Do not pass pointers to local variables to non-`raii_thread's](#Rconc-pass)
10568-
* [CP.31: Pass small amounts of data between threads by value, reather by reference or pointer](#Rconc-data)
10568+
* [CP.31: Pass small amounts of data between threads by value, rather than by reference or pointer](#Rconc-data)
1056910569
* [CP.32: To share ownership beween unrelated `thread`s use `shared_ptr`](#Rconc-shared)
1057010570
* [CP.40: Minimize context switching](#Rconc-switch)
1057110571
* [CP.41: Minimize thread creation and destruction](#Rconc-create)
@@ -10708,7 +10708,7 @@ If, as it is likely, `f()` invokes operations on `*this`, we must make sure that
1070810708

1070910709
##### Reason
1071010710

10711-
To maintain pointer safety and avoid leaks, we need to consider what pointers a used by a `thread`.
10711+
To maintain pointer safety and avoid leaks, we need to consider what pointers are used by a `thread`.
1071210712
If a `thread` joins, we can safely pass pointers to objects in the scope of the `thread` and its enclosing scopes.
1071310713

1071410714
##### Example
@@ -10747,7 +10747,7 @@ After that, the usual lifetime and ownership (for local objects) enforcement app
1074710747

1074810748
##### Reason
1074910749

10750-
To maintain pointer safety and avoid leaks, we need to consider what pointers a used by a `thread`.
10750+
To maintain pointer safety and avoid leaks, we need to consider what pointers are used by a `thread`.
1075110751
If a `thread` is detached, we can safely pass pointers to static and free store objects (only).
1075210752

1075310753
##### Example
@@ -10907,7 +10907,7 @@ A `thread` that has not been `detach()`ed when it is destroyed terminates the pr
1090710907

1090810908
###### Reason
1090910909

10910-
In general, you cannot know whether a non-`raii_thread` will outlife your thread (so that those pointers will become invalid.
10910+
In general, you cannot know whether a non-`raii_thread` will outlive the scope of the variables, so that those pointers will become invalid.
1091110911

1091210912
##### Example, bad
1091310913

@@ -10919,7 +10919,7 @@ In general, you cannot know whether a non-`raii_thread` will outlife your thread
1091910919
t0.detach();
1092010920
}
1092110921

10922-
The detach` may not be so easy to spot.
10922+
The `detach` may not be so easy to spot.
1092310923
Use a `raii_thread` or don't pass the pointer.
1092410924

1092510925
##### Example, bad
@@ -10928,10 +10928,10 @@ Use a `raii_thread` or don't pass the pointer.
1092810928

1092910929
##### Enforcement
1093010930

10931-
Flage pointers to locals passed in the constructor of a plain `thread`.
10931+
Flag pointers to locals passed in the constructor of a plain `thread`.
1093210932

1093310933

10934-
### <a name="Rconc-switch"></a>CP.31: Pass small amounts of data between threads by value, reather by reference or pointer
10934+
### <a name="Rconc-switch"></a>CP.31: Pass small amounts of data between threads by value, rather by reference or pointer
1093510935

1093610936
##### Reason
1093710937

@@ -10940,7 +10940,7 @@ Copying naturally gives unique ownership (simplifies code) and eliminates the po
1094010940

1094110941
##### Note
1094210942

10943-
Defining "small amount" precisely and is impossible.
10943+
Defining "small amount" precisely is impossible.
1094410944

1094510945
##### Example
1094610946

@@ -10955,7 +10955,7 @@ Defining "small amount" precisely and is impossible.
1095510955

1095610956
The call of `modify1` involves copying two `string` values; the call of `modify2` does not.
1095710957
On the other hand, the implementation of `modify1` is exactly as we would have written in for single-threaded code,
10958-
wheread the implementation of `modify2` will need some form of locking to avoid data races.
10958+
whereas the implementation of `modify2` will need some form of locking to avoid data races.
1095910959
If the string is short (say 10 characters), the call of `modify1` can be surprisingly fast;
1096010960
essentially all the cost is in the `thread` switch. If the string is long (say 1,000,000 characters), copying it twice
1096110961
is probably not a good idea.
@@ -10972,7 +10972,7 @@ message passing or shared memory.
1097210972

1097310973
##### Reason
1097410974

10975-
If treads are unrelated (that is, not known to be in the same scope or one within the lifetime of the other)
10975+
If threads are unrelated (that is, not known to be in the same scope or one within the lifetime of the other)
1097610976
and they need to share free store memory that needs to be deleted, a `shared_ptr` (or equivalent) is the only
1097710977
safe way to ensure proper deletion.
1097810978

@@ -10982,7 +10982,7 @@ safe way to ensure proper deletion.
1098210982

1098310983
##### Note
1098410984

10985-
* A static object (e.g. a global) can be shard because it is not owned in the sense that some thread is responsible for it's deletion.
10985+
* A static object (e.g. a global) can be shared because it is not owned in the sense that some thread is responsible for it's deletion.
1098610986
* An object on free store that is never to be deleted can be shared.
1098710987
* An object owned by one thread can be safely shared with another as long as that second thread doesn't outlive the owner.
1098810988

@@ -10995,7 +10995,7 @@ safe way to ensure proper deletion.
1099510995

1099610996
##### Reason
1099710997

10998-
Context swtiches are expesive.
10998+
Context swtiches are expensive.
1099910999

1100011000
##### Example
1100111001

@@ -11054,7 +11054,7 @@ Instead, we could have a set of pre-created worker threads processing the messag
1105411054

1105511055
###### Note
1105611056

11057-
If you system has a good thread pool, use it.
11057+
If your system has a good thread pool, use it.
1105811058
If your system has a good message queue, use it.
1105911059

1106011060
##### Enforcement
@@ -11129,7 +11129,7 @@ it will immediately go back to sleep, waiting.
1112911129

1113011130
##### Enforcement
1113111131

11132-
Flag all `waits` without conditions.
11132+
Flag all `wait`s without conditions.
1113311133

1113411134

1113511135
### <a name="Rconc-time"></a>CP.43: Minimize time spent in a critical section

0 commit comments

Comments
 (0)