188
188
189
189
< p class ="text-right "> < small >
190
190
最終更新日時(UTC):
191
- < span itemprop ="datePublished " content ="2025-02-05T10:01:51 ">
192
- 2025年02月05日 10時01分51秒
191
+ < span itemprop ="datePublished " content ="2025-02-06T01:48:43 ">
192
+ 2025年02月06日 01時48分43秒
193
193
</ span >
194
194
< br />
195
195
< span itemprop ="author " itemscope itemtype ="http://schema.org/Person ">
@@ -264,7 +264,7 @@ <h2>例</h2>
264
264
< p > < div class ="yata " id ="25bbbcfcc369bbb4bef5ac826f2edf4bf1bbd262 "> < div class ="codehilite "> < pre > < span > </ span > < code > < span class ="cp "> #include</ span > < span class ="cpf "> < a href ="../atomic.html "> <atomic></ a > </ span > < span class ="cp "> </ span >
265
265
< span class ="cp "> #include</ span > < span class ="cpf "> < a href ="../mutex.html "> <mutex></ a > </ span > < span class ="cp "> </ span >
266
266
< span class ="cp "> #include</ span > < span class ="cpf "> < a href ="../thread.html "> <thread></ a > </ span > < span class ="cp "> </ span >
267
- < span class ="cp "> #include</ span > < span class ="cpf "> <rcu></ span > < span class ="cp "> </ span >
267
+ < span class ="cp "> #include</ span > < span class ="cpf "> < a href =" ../rcu.html " > <rcu></ a > </ span > < span class ="cp "> </ span >
268
268
269
269
< span class ="k "> struct</ span > < span class ="nl "> Data</ span > < span class ="p "> :</ span > < span class ="n "> < span style ="color:#ff0000 "> std::rcu_obj_base</ span > </ span > < span class ="o "> <</ span > < span class ="n "> Data</ span > < span class ="o "> ></ span > < span class ="p "> {</ span >
270
270
< span class ="kt "> int</ span > < span class ="n "> m1</ span > < span class ="p "> ,</ span > < span class ="n "> m2</ span > < span class ="p "> ;</ span >
@@ -286,21 +286,21 @@ <h2>例</h2>
286
286
< span class ="p "> {</ span >
287
287
< span class ="n "> Data</ span > < span class ="o "> *</ span > < span class ="n "> newdata</ span > < span class ="o "> =</ span > < span class ="k "> new</ span > < span class ="n "> Data</ span > < span class ="p "> {</ span > < span class ="mi "> 1</ span > < span class ="p "> ,</ span > < span class ="mi "> 2</ span > < span class ="p "> };</ span >
288
288
< span class ="c1 "> // 新しいデータで共有データを更新(Update)</ span >
289
- < span class ="n "> Data</ span > < span class ="o "> *</ span > < span class ="n "> old_data</ span > < span class ="o "> =</ span > < span class ="n "> data</ span > < span class ="p "> .</ span > < span class ="n "> exchange</ span > < span class ="p "> (</ span > < span class ="n "> newdata</ span > < span class ="p "> );</ span >
289
+ < span class ="n "> Data</ span > < span class ="o "> *</ span > < span class ="n "> old_data</ span > < span class ="o "> =</ span > < span class ="n "> data</ span > < span class ="p "> .</ span > < span class ="n "> < a href =" ../atomic/atomic/ exchange.html " > exchange </ a > </ span > < span class ="p "> (</ span > < span class ="n "> newdata</ span > < span class ="p "> );</ span >
290
290
291
291
< span class ="c1 "> // 古いデータを読み取り中のスレッドがなくなったタイミングで</ span >
292
292
< span class ="c1 "> // データ領域の回収(メモリ解放)を行うようスケジューリングする</ span >
293
- < span class ="n "> old_data</ span > < span class ="o "> -></ span > < span class ="n "> retire</ span > < span class ="p "> () ;</ span >
293
+ < span class ="n "> old_data</ span > < span class ="o "> -></ span > < span class ="n "> < a href =" rcu_obj_base/ retire.html " > retire() </ a > </ span > < span class ="p "> ;</ span >
294
294
< span class ="p "> }</ span >
295
295
296
296
< span class ="kt "> int</ span > < span class ="nf "> main</ span > < span class ="p "> ()</ span >
297
297
< span class ="p "> {</ span >
298
298
< span class ="c1 "> // 共有データ初期化</ span >
299
299
< span class ="n "> Data</ span > < span class ="o "> *</ span > < span class ="n "> newdata</ span > < span class ="o "> =</ span > < span class ="k "> new</ span > < span class ="n "> Data</ span > < span class ="p "> {</ span > < span class ="mi "> 0</ span > < span class ="p "> ,</ span > < span class ="mi "> 0</ span > < span class ="p "> };</ span >
300
- < span class ="n "> data</ span > < span class ="p "> .</ span > < span class ="n "> store</ span > < span class ="p "> (</ span > < span class ="n "> newdata</ span > < span class ="p "> );</ span >
300
+ < span class ="n "> data</ span > < span class ="p "> .</ span > < span class ="n "> < a href =" ../atomic/atomic/ store.html " > store </ a > </ span > < span class ="p "> (</ span > < span class ="n "> newdata</ span > < span class ="p "> );</ span >
301
301
302
302
< span class ="c1 "> // 共有データへ並行アクセス</ span >
303
- < span class ="n "> std </ span > < span class =" o " > :: </ span > < span class =" n " > jthread </ span > < span class ="n "> th</ span > < span class ="p "> {[]</ span > < span class ="p "> {</ span >
303
+ < span class ="n "> < a href =" ../thread/jthread.html " > std::jthread </ a > </ span > < span class ="n "> th</ span > < span class ="p "> {[]</ span > < span class ="p "> {</ span >
304
304
< span class ="k "> for</ span > < span class ="p "> (</ span > < span class ="kt "> int</ span > < span class ="n "> i</ span > < span class ="o "> =</ span > < span class ="mi "> 0</ span > < span class ="p "> ;</ span > < span class ="n "> i</ span > < span class ="o "> <</ span > < span class ="mi "> 3</ span > < span class ="p "> ;</ span > < span class ="n "> i</ span > < span class ="o "> ++</ span > < span class ="p "> )</ span > < span class ="p "> {</ span >
305
305
< span class ="n "> reader</ span > < span class ="p "> ();</ span >
306
306
< span class ="p "> }</ span >
0 commit comments