Skip to content

Commit be304fe

Browse files
committed
R.1 example: change names according to NL.8
1 parent 0af83de commit be304fe

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

CppCoreGuidelines.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7588,17 +7588,17 @@ Consider:
75887588

75897589
void send(X* x, cstring_span destination)
75907590
{
7591-
auto port = OpenPort(destination);
7591+
auto port = open_port(destination);
75927592
my_mutex.lock();
75937593
// ...
7594-
Send(port, x);
7594+
send(port, x);
75957595
// ...
75967596
my_mutex.unlock();
7597-
ClosePort(port);
7597+
close_port(port);
75987598
delete x;
75997599
}
76007600

7601-
In this code, you have to remember to `unlock`, `ClosePort`, and `delete` on all paths, and do each exactly once.
7601+
In this code, you have to remember to `unlock`, `close_port`, and `delete` on all paths, and do each exactly once.
76027602
Further, if any of the code marked `...` throws an exception, then `x` is leaked and `my_mutex` remains locked.
76037603

76047604
##### Example
@@ -7610,7 +7610,7 @@ Consider:
76107610
Port port{destination}; // port owns the PortHandle
76117611
lock_guard<mutex> guard{my_mutex}; // guard owns the lock
76127612
// ...
7613-
Send(port, x);
7613+
send(port, x);
76147614
// ...
76157615
} // automatically unlocks my_mutex and deletes the pointer in x
76167616

@@ -7621,8 +7621,8 @@ What is `Port`? A handy wrapper that encapsulates the resource:
76217621
class Port {
76227622
PortHandle port;
76237623
public:
7624-
Port(cstring_span destination) : port{OpenPort(destination)} { }
7625-
~Port() { ClosePort(port); }
7624+
Port(cstring_span destination) : port{open_port(destination)} { }
7625+
~Port() { close_port(port); }
76267626
operator PortHandle() { return port; }
76277627

76287628
// port handles can't usually be cloned, so disable copying and assignment if necessary

0 commit comments

Comments
 (0)