9979
9979
\pnum
9980
9980
The header \tcode {<syncstream>} provides a mechanism
9981
9981
to synchronize execution agents writing to the same stream.
9982
- It defines class templates \tcode {basic_osyncstream} and \tcode {basic_syncbuf}.
9983
- The latter buffers output and transfer the buffered content
9984
- into an object of type \tcode {basic_streambuf<charT, traits>}
9985
- atomically with respect to such transfers
9986
- by other \tcode {basic_syncbuf<charT, traits, Allocator>} objects
9987
- referring to the same \tcode {basic_streambuf<charT, traits>} object.
9988
- The transfer occurs when \tcode {emit()} is called
9989
- and when the \tcode {basic_syncbuf<charT, traits, Allocator>} object is destroyed.
9990
9982
9991
9983
\rSec 2[syncstream.syncbuf]{Class template \tcode {basic_syncbuf}}
9992
9984
10040
10032
}
10041
10033
\end {codeblock }
10042
10034
10035
+ \pnum
10036
+ Class template \tcode {basic_syncbuf} stores character data
10037
+ written to it, known as the associated output, into internal
10038
+ buffers allocated using the object's allocator.
10039
+ The associated output is transferred to the
10040
+ wrapped stream buffer object \tcode {*wrapped}
10041
+ when \tcode {emit()} is called
10042
+ or when the \tcode {basic_syncbuf} object is destroyed.
10043
+ Such transfers are atomic with respect to transfers
10044
+ by other \tcode {basic_syncbuf} objects
10045
+ with the same wrapped stream buffer object.
10046
+
10043
10047
\rSec 3[syncstream.syncbuf.cons]{Construction and destruction}
10044
10048
10045
10049
\indexlibrary {\idxcode {basic_syncbuf}!constructor}%
10051
10055
\pnum
10052
10056
\effects
10053
10057
Constructs the \tcode {basic_syncbuf} object and
10054
- sets \tcode {wrapped} to \tcode {obuf}
10055
- which will be the final destination of associated output.
10058
+ sets \tcode {wrapped} to \tcode {obuf}.
10056
10059
10057
10060
\pnum
10058
10061
\remarks
@@ -10062,11 +10065,14 @@
10062
10065
10063
10066
\pnum
10064
10067
\throws
10065
- Nothing unless constructing a mutex or allocating memory throws.
10068
+ Nothing unless an exception is thrown
10069
+ by the construction of a mutex or
10070
+ by memory allocation.
10066
10071
10067
10072
\pnum
10068
10073
\postconditions
10069
- \tcode {get_wrapped() == obuf \&\& get_allocator() == allocator}.
10074
+ \tcode {get_wrapped() == obuf} and
10075
+ \tcode {get_allocator() == allocator} are \tcode {true}.
10070
10076
\end {itemdescr }
10071
10077
10072
10078
\indexlibrary {\idxcode {basic_syncbuf}!constructor}%
10089
10095
will be stored in \tcode {*this} afterwards.
10090
10096
\tcode {other.rdbuf()->pbase() == other.rdbuf()->pptr()}
10091
10097
and
10092
- \tcode {other.get_wrapped() == nullptr}.
10098
+ \tcode {other.get_wrapped() == nullptr}
10099
+ are \tcode {true}.
10093
10100
10094
10101
\pnum
10095
10102
\remarks
10110
10117
10111
10118
\pnum
10112
10119
\throws
10113
- Nothing. If an exception is thrown from \tcode {emit()},
10114
- that exception is caught and ignored.
10120
+ Nothing.
10121
+ If an exception is thrown from \tcode {emit()},
10122
+ the destructor catches and ignores that exception.
10115
10123
\end {itemdescr }
10116
10124
10117
10125
\rSec 3[syncstream.syncbuf.assign]{Assignment and swap}
10138
10146
\postconditions
10139
10147
\begin {itemize }
10140
10148
\item
10141
- \tcode {rhs.get_wrapped() == nullptr}.
10149
+ \tcode {rhs.get_wrapped() == nullptr} is \tcode {true} .
10142
10150
\item
10143
- \tcode {this->get_allocator() == rhs.get_allocator()} when
10151
+ \tcode {this->get_allocator() == rhs.get_allocator()} is \tcode {true} when
10144
10152
\begin {codeblock }
10145
10153
allocator_traits<Allocator>::propagate_on_container_move_assignment::value
10146
10154
\end {codeblock }
10162
10170
\begin {itemdescr }
10163
10171
\pnum
10164
10172
\requires
10173
+ Either
10165
10174
\tcode {allocator_traits<Allocator>::propagate_on_container_swap::value}
10166
- or \tcode {this->get_allocator() == other.get_allocator()}.
10175
+ is \tcode {true}
10176
+ or
10177
+ \tcode {this->get_allocator() == other.get_allocator()}
10178
+ is \tcode {true}.
10167
10179
10168
10180
\pnum
10169
10181
\effects
@@ -10180,27 +10192,27 @@
10180
10192
\begin {itemdescr }
10181
10193
\pnum
10182
10194
\effects
10183
- Atomically transfers the contents of the internal buffer
10195
+ Atomically transfers the associated output of \tcode {*this}
10184
10196
to the stream buffer \tcode {*wrapped},
10185
- so that they appear in the output stream
10197
+ so that it appears in the output stream
10186
10198
as a contiguous sequence of characters.
10187
- If and only if a call was made to \tcode {sync ()}
10188
- since the last call of \tcode {emit ()},
10189
- \tcode {wrapped->pubsync ()} is called .
10199
+ \tcode {wrapped->pubsync ()} is called
10200
+ if and only if a call was made to \tcode {sync ()}
10201
+ since the most recent call to \tcode {emit ()}, if any .
10190
10202
10191
10203
\pnum
10192
10204
\returns
10193
10205
\tcode {true} if all of the following conditions hold;
10194
10206
otherwise \tcode {false}:
10195
10207
\begin {itemize }
10196
- \item \tcode {wrapped != nullptr}.
10208
+ \item \tcode {wrapped == nullptr} is \tcode {false }.
10197
10209
\item All of the characters in the associated output were successfully transferred.
10198
10210
\item The call to \tcode {wrapped->pubsync()} (if any) succeeded.
10199
10211
\end {itemize }
10200
10212
10201
10213
\pnum
10202
10214
\postconditions
10203
- On success the associated output is empty.
10215
+ On success, the associated output is empty.
10204
10216
10205
10217
\pnum
10206
10218
\sync
10237
10249
\begin {itemdescr }
10238
10250
\pnum
10239
10251
\returns
10240
- A copy of the allocator set in the constructor or from assignment.
10252
+ A copy of the allocator that was set in the constructor or assignment operator .
10241
10253
\end {itemdescr }
10242
10254
10243
10255
\indexlibrarymember {set_emit_on_sync}{basic_syncbuf}%
@@ -10261,10 +10273,10 @@
10261
10273
\begin {itemdescr }
10262
10274
\pnum
10263
10275
\effects
10264
- Record that the wrapped stream buffer is to be flushed.
10265
- Then, if \tcode {emit_on_sync == true}, calls \tcode {emit()}.
10276
+ Records that the wrapped stream buffer is to be flushed.
10277
+ Then, if \tcode {emit_on_sync} is \tcode { true}, calls \tcode {emit()}.
10266
10278
\begin {note }
10267
- If \tcode {emit_on_sync == false},
10279
+ If \tcode {emit_on_sync} is \tcode { false},
10268
10280
the actual flush is delayed until a call to \tcode {emit()}.
10269
10281
\end {note }
10270
10282
@@ -10370,20 +10382,19 @@
10370
10382
\begin {itemdescr }
10371
10383
\pnum
10372
10384
\effects
10373
- Initializes \tcode {sb} from \tcode {buf} and \tcode {allocator} and
10374
- initializes the base class with \tcode {basic_ostream(\& sb)}.
10385
+ Initializes \tcode {sb} from \tcode {buf} and \tcode {allocator}.
10386
+ Initializes the base class with \tcode {basic_ostream(\& sb)}.
10375
10387
10376
10388
\pnum
10377
10389
\begin {note }
10378
- If the wrapped stream buffer pointer
10379
- refers to a user provided stream buffer
10380
- then its implementation must be aware that its member functions
10390
+ The member functions of the provided stream buffer
10381
10391
might be called from \tcode {emit()} while a lock is held.
10392
+ Care should be taken to ensure that this does not result in deadlock.
10382
10393
\end {note }
10383
10394
10384
10395
\pnum
10385
10396
\postconditions
10386
- \tcode {get_wrapped() == buf}.
10397
+ \tcode {get_wrapped() == buf} is \tcode {true} .
10387
10398
\end {itemdescr }
10388
10399
10389
10400
\indexlibrary {\idxcode {basic_osyncstream}!constructor}%
@@ -10394,18 +10405,16 @@
10394
10405
\begin {itemdescr }
10395
10406
\pnum
10396
10407
\effects
10397
- Move constructs from \tcode {other}.
10398
- This is accomplished by move constructing the base class,
10399
- and the contained \tcode {basic_syncbuf} \tcode {sb}.
10400
- Next \tcode {basic_ostream<charT, traits>::set_rdbuf(\& sb)}
10401
- is called to install the \tcode {basic_syncbuf} \tcode {sb}.
10408
+ Move constructs the base class
10409
+ and \tcode {sb} from the corresponding subobjects of \tcode {other},
10410
+ and calls \tcode {basic_ostream<charT, traits>::set_rdbuf(\& sb)}.
10402
10411
10403
10412
\pnum
10404
10413
\postconditions
10405
10414
The value returned by \tcode {get_wrapped()}
10406
10415
is the value returned by \tcode {os.get_wrapped()}
10407
10416
prior to calling this constructor.
10408
- \tcode {nullptr == other.get_wrapped()}.
10417
+ \tcode {nullptr == other.get_wrapped()} is \tcode {true} .
10409
10418
\end {itemdescr }
10410
10419
10411
10420
\indexlibrary {\idxcode {basic_osyncstream}!destructor}%
10443
10452
10444
10453
\pnum
10445
10454
\postconditions
10446
- \tcode {nullptr == rhs.get_wrapped()}.
10455
+ \tcode {nullptr == rhs.get_wrapped()} is \tcode {true} .
10447
10456
\tcode {get_wrapped()} returns the value
10448
10457
previously returned by \tcode {rhs.get_wrapped()}.
10449
10458
\end {itemdescr }
10459
10468
\pnum
10460
10469
\effects
10461
10470
Calls \tcode {sb.emit()}.
10462
- If this call returns \tcode {false},
10471
+ If that call returns \tcode {false},
10463
10472
calls \tcode {setstate(ios::badbit)}.
10464
10473
10465
10474
\pnum
0 commit comments