You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* delay = -1 ; // if timeout millis is negatif, then we keep last timeout calculation.
190
+
* }
191
+
*
192
+
* if ( counter >= 10000 ) {
193
+
* message("worker class, counter >= 10000");
194
+
* } else {
195
+
* message("worker class, counter < 10000");
196
+
* }
197
+
* } // end of critical section
198
+
*
199
+
* pthread::this_thread::sleep(200);
200
+
* };
201
+
*
202
+
* private:
203
+
* std::string msg ;
204
+
* int _sleep;
205
+
* };
206
+
*
207
+
* int main(int argc, const char * argv[]) {
208
+
*
209
+
* pthread::thread_group threads(true); // indicate that we want to join referenced threads when deallocating this instance.
210
+
* for (auto x = 10 ; x > 0 ; x--){
211
+
* threads.add( new worker("herbert"));
212
+
* }
213
+
*
214
+
* threads.start(); // start running all threads
215
+
*
216
+
* for ( auto x = 20000 ; x > 0 ; x--){
217
+
* pthread::lock_guard<pthread::mutex> lck(mtx);
218
+
* counter++ ;
219
+
* }
220
+
*
221
+
* condition.notify_all();
222
+
* }
223
+
*
220
224
* </code></pre>
221
225
*/
222
226
classabstract_thread: publicrunnable {
@@ -243,19 +247,19 @@ namespace pthread {
243
247
*
244
248
* **A thread_group deletes the thread that were registered/added to it.**
245
249
*
246
-
<pre><code>
247
-
int main(int argc, const char * argv[]) {
248
-
249
-
pthread::thread_group threads; // this instance will free any registered thread when it will get out of scope
250
-
251
-
for (auto x = 10 ; x > 0 ; x--){
252
-
threads.add( new worker("herbert")); // register threads, they will run when start() is called
253
-
}
254
-
255
-
threads.start(); // start running all threads
256
-
threads.join(); // wait for registered threads to join
257
-
} // scope end
258
-
250
+
* <pre><code>
251
+
* int main(int argc, const char * argv[]) {
252
+
*
253
+
* pthread::thread_group threads; // this instance will free any registered thread when it will get out of scope
254
+
*
255
+
* for (auto x = 10 ; x > 0 ; x--){
256
+
* threads.add( new worker("herbert")); // register threads, they will run when start() is called
257
+
* }
258
+
*
259
+
* threads.start(); // start running all threads
260
+
* threads.join(); // wait for registered threads to join
261
+
* } // scope end
262
+
*
259
263
* </code></pre>
260
264
*/
261
265
classthread_group{
@@ -264,7 +268,11 @@ namespace pthread {
264
268
*
265
269
* @param destructor_joins_first if true then destructor tries to wait for all registered threads to join the calling one before deleting thread instances.
0 commit comments