Welcome to mirror list, hosted at ThFree Co, Russian Federation.

classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html - github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 806a8ea5b09a25e5ae4c35cb8b83ce6f0b46a0d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>LLFIO: llfio_v2_xxx::algorithm::shared_fs_mutex::atomic_append Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">LLFIO
   &#160;<span id="projectnumber">v2.00 late beta</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">llfio_v2_xxx::algorithm::shared_fs_mutex::atomic_append Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Scalable many entity shared/exclusive file system based lock.  
 <a href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#details">More...</a></p>

<p><code>#include &quot;atomic_append.hpp&quot;</code></p>
<div class="dynheader">
Inheritance diagram for llfio_v2_xxx::algorithm::shared_fs_mutex::atomic_append:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.png" usemap="#llfio_5Fv2_5Fxxx::algorithm::shared_5Ffs_5Fmutex::atomic_5Fappend_map" alt=""/>
  <map id="llfio_5Fv2_5Fxxx::algorithm::shared_5Ffs_5Fmutex::atomic_5Fappend_map" name="llfio_5Fv2_5Fxxx::algorithm::shared_5Ffs_5Fmutex::atomic_5Fappend_map">
<area href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html" title="Abstract base class for an object which protects shared filing system resources." alt="llfio_v2_xxx::algorithm::shared_fs_mutex::shared_fs_mutex" shape="rect" coords="0,0,337,24"/>
  </map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a31ffa04a6276ce1a59ccb1c6d21ae069"><td class="memItemLeft" align="right" valign="top"><a id="a31ffa04a6276ce1a59ccb1c6d21ae069"></a>
using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a31ffa04a6276ce1a59ccb1c6d21ae069">entity_type</a> = <a class="el" href="structllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex_1_1entity__type.html">shared_fs_mutex::entity_type</a></td></tr>
<tr class="memdesc:a31ffa04a6276ce1a59ccb1c6d21ae069"><td class="mdescLeft">&#160;</td><td class="mdescRight">The type of an entity id. <br /></td></tr>
<tr class="separator:a31ffa04a6276ce1a59ccb1c6d21ae069"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d76403bdfa829d3144931db2ed6948c"><td class="memItemLeft" align="right" valign="top"><a id="a2d76403bdfa829d3144931db2ed6948c"></a>
using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a2d76403bdfa829d3144931db2ed6948c">entities_type</a> = <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#aec91125605e5a8379b7616b7f90d1232">shared_fs_mutex::entities_type</a></td></tr>
<tr class="memdesc:a2d76403bdfa829d3144931db2ed6948c"><td class="mdescLeft">&#160;</td><td class="mdescRight">The type of a sequence of entities. <br /></td></tr>
<tr class="separator:a2d76403bdfa829d3144931db2ed6948c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a9ad4f626c7381bf3a2121c996ae1a17c"><td class="memItemLeft" align="right" valign="top"><a id="a9ad4f626c7381bf3a2121c996ae1a17c"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a9ad4f626c7381bf3a2121c996ae1a17c">atomic_append</a> (const <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a> &amp;)=delete</td></tr>
<tr class="memdesc:a9ad4f626c7381bf3a2121c996ae1a17c"><td class="mdescLeft">&#160;</td><td class="mdescRight">No copy construction. <br /></td></tr>
<tr class="separator:a9ad4f626c7381bf3a2121c996ae1a17c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abed292cfeab855d43b220a0ee176a1f6"><td class="memItemLeft" align="right" valign="top"><a id="abed292cfeab855d43b220a0ee176a1f6"></a>
<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#abed292cfeab855d43b220a0ee176a1f6">operator=</a> (const <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a> &amp;)=delete</td></tr>
<tr class="memdesc:abed292cfeab855d43b220a0ee176a1f6"><td class="mdescLeft">&#160;</td><td class="mdescRight">No copy assignment. <br /></td></tr>
<tr class="separator:abed292cfeab855d43b220a0ee176a1f6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2dad7f9e1f8212f8556bce1c059c641b"><td class="memItemLeft" align="right" valign="top"><a id="a2dad7f9e1f8212f8556bce1c059c641b"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a2dad7f9e1f8212f8556bce1c059c641b">atomic_append</a> (<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a> &amp;&amp;o) noexcept</td></tr>
<tr class="memdesc:a2dad7f9e1f8212f8556bce1c059c641b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Move constructor. <br /></td></tr>
<tr class="separator:a2dad7f9e1f8212f8556bce1c059c641b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab4f072d8b41d50dc942f48e0ca291e16"><td class="memItemLeft" align="right" valign="top"><a id="ab4f072d8b41d50dc942f48e0ca291e16"></a>
<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#ab4f072d8b41d50dc942f48e0ca291e16">operator=</a> (<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a> &amp;&amp;o) noexcept</td></tr>
<tr class="memdesc:ab4f072d8b41d50dc942f48e0ca291e16"><td class="mdescLeft">&#160;</td><td class="mdescRight">Move assign. <br /></td></tr>
<tr class="separator:ab4f072d8b41d50dc942f48e0ca291e16"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3ff0de8b3c00cccd97154d6e59be3ec5"><td class="memItemLeft" align="right" valign="top"><a id="a3ff0de8b3c00cccd97154d6e59be3ec5"></a>
const <a class="el" href="classllfio__v2__xxx_1_1file__handle.html">file_handle</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a3ff0de8b3c00cccd97154d6e59be3ec5">handle</a> () const noexcept</td></tr>
<tr class="memdesc:a3ff0de8b3c00cccd97154d6e59be3ec5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the handle to file being used for this lock. <br /></td></tr>
<tr class="separator:a3ff0de8b3c00cccd97154d6e59be3ec5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9a1efb3416df74145cd6d8a91c01350c"><td class="memItemLeft" align="right" valign="top"><a id="a9a1efb3416df74145cd6d8a91c01350c"></a>
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a9a1efb3416df74145cd6d8a91c01350c">unlock</a> (<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a2d76403bdfa829d3144931db2ed6948c">entities_type</a> entities, unsigned long long hint) noexcept final</td></tr>
<tr class="memdesc:a9a1efb3416df74145cd6d8a91c01350c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Unlock a previously locked sequence of entities. <br /></td></tr>
<tr class="separator:a9a1efb3416df74145cd6d8a91c01350c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4cdf15b69bf6f375ec7083d639f76358"><td class="memItemLeft" align="right" valign="top"><a id="a4cdf15b69bf6f375ec7083d639f76358"></a>
<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a31ffa04a6276ce1a59ccb1c6d21ae069">entity_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#a4cdf15b69bf6f375ec7083d639f76358">entity_from_buffer</a> (const char *buffer, size_t bytes, bool exclusive=true) noexcept</td></tr>
<tr class="memdesc:a4cdf15b69bf6f375ec7083d639f76358"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generates an entity id from a sequence of bytes. <br /></td></tr>
<tr class="separator:a4cdf15b69bf6f375ec7083d639f76358"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afb28aedaf5caa53e851165a4f1927207"><td class="memTemplParams" colspan="2"><a id="afb28aedaf5caa53e851165a4f1927207"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:afb28aedaf5caa53e851165a4f1927207"><td class="memTemplItemLeft" align="right" valign="top"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a31ffa04a6276ce1a59ccb1c6d21ae069">entity_type</a>&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#afb28aedaf5caa53e851165a4f1927207">entity_from_string</a> (const std::basic_string&lt; T &gt; &amp;str, bool exclusive=true) noexcept</td></tr>
<tr class="memdesc:afb28aedaf5caa53e851165a4f1927207"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generates an entity id from a string. <br /></td></tr>
<tr class="separator:afb28aedaf5caa53e851165a4f1927207"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8d62fe0c18bcfb1ade9ff9c7bb00e70b"><td class="memItemLeft" align="right" valign="top"><a id="a8d62fe0c18bcfb1ade9ff9c7bb00e70b"></a>
<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a31ffa04a6276ce1a59ccb1c6d21ae069">entity_type</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#a8d62fe0c18bcfb1ade9ff9c7bb00e70b">random_entity</a> (bool exclusive=true) noexcept</td></tr>
<tr class="memdesc:a8d62fe0c18bcfb1ade9ff9c7bb00e70b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generates a cryptographically random entity id. <br /></td></tr>
<tr class="separator:a8d62fe0c18bcfb1ade9ff9c7bb00e70b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab33ccb32052633a55cb3bb5d1bbdf52b"><td class="memItemLeft" align="right" valign="top"><a id="ab33ccb32052633a55cb3bb5d1bbdf52b"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#ab33ccb32052633a55cb3bb5d1bbdf52b">fill_random_entities</a> (span&lt; <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a31ffa04a6276ce1a59ccb1c6d21ae069">entity_type</a> &gt; seq, bool exclusive=true) noexcept</td></tr>
<tr class="memdesc:ab33ccb32052633a55cb3bb5d1bbdf52b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Fills a sequence of entity ids with cryptographic randomness. Much faster than calling random_entity() individually. <br /></td></tr>
<tr class="separator:ab33ccb32052633a55cb3bb5d1bbdf52b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adc6284803080e42505ba812d4711bb74"><td class="memItemLeft" align="right" valign="top"><a id="adc6284803080e42505ba812d4711bb74"></a>
result&lt; <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex_1_1entities__guard.html">entities_guard</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#adc6284803080e42505ba812d4711bb74">lock</a> (<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a2d76403bdfa829d3144931db2ed6948c">entities_type</a> entities, <a class="el" href="structllfio__v2__xxx_1_1deadline.html">deadline</a> d=<a class="el" href="structllfio__v2__xxx_1_1deadline.html">deadline</a>(), bool spin_not_sleep=false) noexcept</td></tr>
<tr class="memdesc:adc6284803080e42505ba812d4711bb74"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lock all of a sequence of entities for exclusive or shared access. <br /></td></tr>
<tr class="separator:adc6284803080e42505ba812d4711bb74"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a33dcc1d37df90ac5dd85a754f9ffce04"><td class="memItemLeft" align="right" valign="top"><a id="a33dcc1d37df90ac5dd85a754f9ffce04"></a>
result&lt; <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex_1_1entities__guard.html">entities_guard</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#a33dcc1d37df90ac5dd85a754f9ffce04">lock</a> (<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a31ffa04a6276ce1a59ccb1c6d21ae069">entity_type</a> entity, <a class="el" href="structllfio__v2__xxx_1_1deadline.html">deadline</a> d=<a class="el" href="structllfio__v2__xxx_1_1deadline.html">deadline</a>(), bool spin_not_sleep=false) noexcept</td></tr>
<tr class="memdesc:a33dcc1d37df90ac5dd85a754f9ffce04"><td class="mdescLeft">&#160;</td><td class="mdescRight">Lock a single entity for exclusive or shared access. <br /></td></tr>
<tr class="separator:a33dcc1d37df90ac5dd85a754f9ffce04"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a051822a4942c7f45b0491ab4385aacd3"><td class="memItemLeft" align="right" valign="top"><a id="a051822a4942c7f45b0491ab4385aacd3"></a>
result&lt; <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex_1_1entities__guard.html">entities_guard</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#a051822a4942c7f45b0491ab4385aacd3">try_lock</a> (<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a2d76403bdfa829d3144931db2ed6948c">entities_type</a> entities) noexcept</td></tr>
<tr class="memdesc:a051822a4942c7f45b0491ab4385aacd3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to lock all of a sequence of entities for exclusive or shared access. <br /></td></tr>
<tr class="separator:a051822a4942c7f45b0491ab4385aacd3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5a7f463e9235bb95ddd84b69e2642613"><td class="memItemLeft" align="right" valign="top"><a id="a5a7f463e9235bb95ddd84b69e2642613"></a>
result&lt; <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex_1_1entities__guard.html">entities_guard</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html#a5a7f463e9235bb95ddd84b69e2642613">try_lock</a> (<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a31ffa04a6276ce1a59ccb1c6d21ae069">entity_type</a> entity) noexcept</td></tr>
<tr class="memdesc:a5a7f463e9235bb95ddd84b69e2642613"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to lock a single entity for exclusive or shared access. <br /></td></tr>
<tr class="separator:a5a7f463e9235bb95ddd84b69e2642613"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a53cfcfafa373bdb5a4d16f325b95d700"><td class="memItemLeft" align="right" valign="top">static result&lt; <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a> &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a53cfcfafa373bdb5a4d16f325b95d700">fs_mutex_append</a> (const <a class="el" href="classllfio__v2__xxx_1_1path__handle.html">path_handle</a> &amp;base, <a class="el" href="classllfio__v2__xxx_1_1path__view.html">path_view</a> lockfile, bool nfs_compatibility=false, bool skip_hashing=false) noexcept</td></tr>
<tr class="separator:a53cfcfafa373bdb5a4d16f325b95d700"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a2b211531334c21185cbc7fc04a982357"><td class="memItemLeft" align="right" valign="top">virtual result&lt; void &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html#a2b211531334c21185cbc7fc04a982357">_lock</a> (<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex_1_1entities__guard.html">entities_guard</a> &amp;out, <a class="el" href="structllfio__v2__xxx_1_1deadline.html">deadline</a> d, bool spin_not_sleep) noexcept final</td></tr>
<tr class="separator:a2b211531334c21185cbc7fc04a982357"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Scalable many entity shared/exclusive file system based lock. </p>
<p>Lock files and byte ranges scale poorly to the number of items being concurrently locked with typically an exponential drop off in performance as the number of items being concurrently locked rises. This file system algorithm solves this problem using IPC via a shared append-only lock file.</p>
<ul>
<li>Compatible with networked file systems (NFS too if the special nfs_compatibility flag is true. Note turning this on is not free of cost if you don't need NFS compatibility).</li>
<li>Nearly constant time to number of entities being locked.</li>
<li>Nearly constant time to number of processes concurrently using the lock (i.e. number of waiters).</li>
<li>Can sleep until a lock becomes free in a power-efficient manner.</li>
<li>Sudden power loss during use is recovered from.</li>
</ul>
<p>Caveats:</p><ul>
<li>Much slower than byte_ranges for few waiters or small number of entities.</li>
<li>Sudden process exit with locks held will deadlock all other users.</li>
<li>Maximum of twelve entities may be locked concurrently.</li>
<li>Wasteful of disk space if used on a non-extents based filing system (e.g. FAT32, ext3). It is best used in <code>/tmp</code> if possible (<code>file_handle::temp_file()</code>). If you really must use a non-extents based filing system, destroy and recreate the object instance periodically to force resetting the lock file's length to zero.</li>
<li>Similarly older operating systems (e.g. Linux &lt; 3.0) do not implement extent hole punching and therefore will also see excessive disk space consumption. Note at the time of writing OS X doesn't implement hole punching at all.</li>
<li><p class="startli">If your OS doesn't have sane byte range locks (OS X, BSD, older Linuxes) and multiple objects in your process use the same lock file, misoperation will occur. Use lock_files instead.</p>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000006">Todo:</a></b></dt><dd><p class="startdd">Implement hole punching once I port that code from LLFIO v1. </p>
<p class="interdd">Decide on some resolution mechanism for sudden process exit. </p>
<p class="enddd">There is a 1 out of 2^64-2 chance of unique id collision. It would be nice if we actually formally checked that our chosen unique id is actually unique. </p>
</dd></dl>
</li>
</ul>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="a2b211531334c21185cbc7fc04a982357"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2b211531334c21185cbc7fc04a982357">&#9670;&nbsp;</a></span>_lock()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">virtual result&lt;void&gt; llfio_v2_xxx::algorithm::shared_fs_mutex::atomic_append::_lock </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex_1_1entities__guard.html">entities_guard</a> &amp;&#160;</td>
          <td class="paramname"><em>out</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structllfio__v2__xxx_1_1deadline.html">deadline</a>&#160;</td>
          <td class="paramname"><em>d</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>spin_not_sleep</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">final</span><span class="mlabel">protected</span><span class="mlabel">virtual</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000008">Todo:</a></b></dt><dd>Read from header.last_known_good immediately if possible in order to avoid a duplicate read later </dd></dl>

<p>Implements <a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1shared__fs__mutex.html">llfio_v2_xxx::algorithm::shared_fs_mutex::shared_fs_mutex</a>.</p>
<div class="fragment"><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;      {</div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;        LLFIO_LOG_FUNCTION_CALL(<span class="keyword">this</span>);</div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;        atomic_append_detail::lock_request lock_request;</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;        <span class="keywordflow">if</span>(out.entities.size() &gt; <span class="keyword">sizeof</span>(lock_request.entities) / <span class="keyword">sizeof</span>(lock_request.entities[0]))</div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;        {</div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;          <span class="keywordflow">return</span> errc::argument_list_too_long;</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;        }</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160; </div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;        std::chrono::steady_clock::time_point began_steady;</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;        std::chrono::system_clock::time_point end_utc;</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;        <span class="keywordflow">if</span>(d)</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;        {</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;          <span class="keywordflow">if</span>((d).steady)</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;          {</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;            began_steady = std::chrono::steady_clock::now();</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;          }</div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;          <span class="keywordflow">else</span></div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;          {</div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;            end_utc = (d).to_time_point();</div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;          }</div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;        }</div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;        <span class="comment">// Fire this if an error occurs</span></div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;        <span class="keyword">auto</span> disableunlock = make_scope_exit([&amp;]() noexcept { out.release(); });</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160; </div>
<div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;        <span class="comment">// Write my lock request immediately</span></div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;        memset(&amp;lock_request, 0, <span class="keyword">sizeof</span>(lock_request));</div>
<div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;        lock_request.unique_id = _unique_id;</div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;        <span class="keyword">auto</span> count = std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t(_header.time_offset);</div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;        lock_request.us_count = std::chrono::duration_cast&lt;std::chrono::microseconds&gt;(count).count();</div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;        lock_request.items = out.entities.size();</div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;        memcpy(lock_request.entities, out.entities.data(), <span class="keyword">sizeof</span>(lock_request.entities[0]) * out.entities.size());</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;        <span class="keywordflow">if</span>(!_skip_hashing)</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;        {</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;          lock_request.hash = QUICKCPPLIB_NAMESPACE::algorithm::hash::fast_hash::hash((<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span> *<span class="keyword">&gt;</span>(&amp;lock_request)) + 16, <span class="keyword">sizeof</span>(lock_request) - 16);</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;        }</div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;        <span class="comment">// My lock request will be the file&#39;s current length or higher</span></div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;        OUTCOME_TRY(<span class="keyword">auto</span> &amp;&amp;my_lock_request_offset, _h.<a class="code" href="classllfio__v2__xxx_1_1file__handle.html#a7991af58283025b80a7225866643f0b4">maximum_extent</a>());</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;        {</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;          OUTCOME_TRYV(_h.<a class="code" href="classllfio__v2__xxx_1_1handle.html#a101620e9fff0c0e8c346af0e9de58b6a">set_append_only</a>(<span class="keyword">true</span>));</div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;          <span class="keyword">auto</span> undo = make_scope_exit([<span class="keyword">this</span>]() noexcept { (void) _h.<a class="code" href="classllfio__v2__xxx_1_1handle.html#a101620e9fff0c0e8c346af0e9de58b6a">set_append_only</a>(<span class="keyword">false</span>); });</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;          file_handle::extent_guard append_guard;</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;          <span class="keywordflow">if</span>(_nfs_compatibility)</div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;          {</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;            <span class="keyword">auto</span> lastbyte = <span class="keyword">static_cast&lt;</span>file_handle::extent_type<span class="keyword">&gt;</span>(-1);</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;            <span class="comment">// Lock up to the beginning of the shadow lock space</span></div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;            lastbyte &amp;= ~(1ULL &lt;&lt; 63U);</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;            OUTCOME_TRY(<span class="keyword">auto</span> &amp;&amp;append_guard_, _h.<a class="code" href="classllfio__v2__xxx_1_1lockable__io__handle.html#a0ece4f0a48e1e67debc438a9742a1f4c">lock_file_range</a>(my_lock_request_offset, lastbyte, <a class="code" href="namespacellfio__v2__xxx.html#ae79486289ff1386b26d1ce60bb797d33aa4293995cfbfa9ce60ce71ade2ff75f7">lock_kind::exclusive</a>));</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;            append_guard = std::move(append_guard_);</div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;          }</div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;          OUTCOME_TRYV(_h.<a class="code" href="classllfio__v2__xxx_1_1io__handle.html#a7848ef15e774eacec7e4446a8c365a3d">write</a>(0, {{reinterpret_cast&lt;byte *&gt;(&amp;lock_request), sizeof(lock_request)}}));</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;        }</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160; </div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;        <span class="comment">// Find the record I just wrote</span></div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;        <span class="keyword">alignas</span>(64) <span class="keywordtype">byte</span> _buffer[4096 + 2048];  <span class="comment">// 6Kb cache line aligned buffer</span></div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;        <span class="comment">// Read onwards from length as reported before I wrote my lock request</span></div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;        <span class="comment">// until I find my lock request. This loop should never actually iterate</span></div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;        <span class="comment">// except under extreme load conditions.</span><span class="comment"></span></div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;<span class="comment">        //! \todo Read from header.last_known_good immediately if possible in order</span></div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;<span class="comment">        //! to avoid a duplicate read later</span></div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;<span class="comment"></span>        <span class="keywordflow">for</span>(;;)</div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;        {</div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;          file_handle::buffer_type req{_buffer, <span class="keyword">sizeof</span>(_buffer)};</div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;          file_handle::io_result&lt;file_handle::buffers_type&gt; readoutcome = _h.<a class="code" href="classllfio__v2__xxx_1_1io__handle.html#ae04ada27942187f03b59044cd1328f49">read</a>({{&amp;req, 1}, my_lock_request_offset});</div>
<div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;          <span class="comment">// Should never happen :)</span></div>
<div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;          <span class="keywordflow">if</span>(readoutcome.has_error())</div>
<div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;          {</div>
<div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;            LLFIO_LOG_FATAL(<span class="keyword">this</span>, <span class="stringliteral">&quot;atomic_append::lock() saw an error when searching for just written data&quot;</span>);</div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;            std::terminate();</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;          }</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;          <span class="keyword">const</span> atomic_append_detail::lock_request *record, *lastrecord;</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;          <span class="keywordflow">for</span>(record = <span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span>atomic_append_detail::lock_request *<span class="keyword">&gt;</span>(readoutcome.value()[0].data()), lastrecord = <span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span>atomic_append_detail::lock_request *<span class="keyword">&gt;</span>(readoutcome.value()[0].data() + readoutcome.value()[0].size()); record &lt; lastrecord &amp;&amp; record-&gt;hash != lock_request.hash;</div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;              ++record)</div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;          {</div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;            my_lock_request_offset += <span class="keyword">sizeof</span>(atomic_append_detail::lock_request);</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;          }</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;          <span class="keywordflow">if</span>(record-&gt;hash == lock_request.hash)</div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;          {</div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;            <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;          }</div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;        }</div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160; </div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;        <span class="comment">// extent_guard is now valid and will be unlocked on error</span></div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;        out.hint = my_lock_request_offset;</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;        disableunlock.release();</div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160; </div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;        <span class="comment">// Lock my request for writing so others can sleep on me</span></div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;        file_handle::extent_guard my_request_guard;</div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;        <span class="keywordflow">if</span>(!spin_not_sleep)</div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;        {</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;          <span class="keyword">auto</span> lock_offset = my_lock_request_offset;</div>
<div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;          <span class="comment">// Set the top bit to use the shadow lock space on Windows</span></div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;          lock_offset |= (1ULL &lt;&lt; 63U);</div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;          OUTCOME_TRY(<span class="keyword">auto</span> &amp;&amp;my_request_guard_, _h.<a class="code" href="classllfio__v2__xxx_1_1lockable__io__handle.html#a0ece4f0a48e1e67debc438a9742a1f4c">lock_file_range</a>(lock_offset, <span class="keyword">sizeof</span>(lock_request), <a class="code" href="namespacellfio__v2__xxx.html#ae79486289ff1386b26d1ce60bb797d33aa4293995cfbfa9ce60ce71ade2ff75f7">lock_kind::exclusive</a>));</div>
<div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;          my_request_guard = std::move(my_request_guard_);</div>
<div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;        }</div>
<div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160; </div>
<div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;        <span class="comment">// Read every record preceding mine until header.first_known_good inclusive</span></div>
<div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;        <span class="keyword">auto</span> record_offset = my_lock_request_offset - <span class="keyword">sizeof</span>(atomic_append_detail::lock_request);</div>
<div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;        <span class="keywordflow">do</span></div>
<div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;        {</div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;        reload:</div>
<div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;          <span class="comment">// Refresh the header and load a snapshot of everything between record_offset</span></div>
<div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;          <span class="comment">// and first_known_good or -6Kb, whichever the sooner</span></div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;          OUTCOME_TRYV(_read_header());</div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;          <span class="comment">// If there are no preceding records, we&#39;re done</span></div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;          <span class="keywordflow">if</span>(record_offset &lt; _header.first_known_good)</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;          {</div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;            <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;          }</div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;          <span class="keyword">auto</span> start_offset = record_offset;</div>
<div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;          <span class="keywordflow">if</span>(start_offset &gt; <span class="keyword">sizeof</span>(_buffer) - <span class="keyword">sizeof</span>(atomic_append_detail::lock_request))</div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;          {</div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;            start_offset -= <span class="keyword">sizeof</span>(_buffer) - <span class="keyword">sizeof</span>(atomic_append_detail::lock_request);</div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;          }</div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;          <span class="keywordflow">else</span></div>
<div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;          {</div>
<div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160;            start_offset = <span class="keyword">sizeof</span>(atomic_append_detail::lock_request);</div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;          }</div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;          <span class="keywordflow">if</span>(start_offset &lt; _header.first_known_good)</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;          {</div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;            start_offset = _header.first_known_good;</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;          }</div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;          assert(record_offset &gt;= start_offset);</div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;          assert(record_offset - start_offset &lt;= <span class="keyword">sizeof</span>(_buffer));</div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;          file_handle::buffer_type req{_buffer, (size_t)(record_offset - start_offset) + <span class="keyword">sizeof</span>(atomic_append_detail::lock_request)};</div>
<div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;          OUTCOME_TRY(<span class="keyword">auto</span> &amp;&amp;batchread, _h.<a class="code" href="classllfio__v2__xxx_1_1io__handle.html#ae04ada27942187f03b59044cd1328f49">read</a>({{&amp;req, 1}, start_offset}));</div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;          assert(batchread[0].size() == record_offset - start_offset + <span class="keyword">sizeof</span>(atomic_append_detail::lock_request));</div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;          <span class="keyword">const</span> atomic_append_detail::lock_request *record = <span class="keyword">reinterpret_cast&lt;</span>atomic_append_detail::lock_request *<span class="keyword">&gt;</span>(batchread[0].data() + batchread[0].size() - <span class="keyword">sizeof</span>(atomic_append_detail::lock_request));</div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;          <span class="keyword">const</span> atomic_append_detail::lock_request *firstrecord = <span class="keyword">reinterpret_cast&lt;</span>atomic_append_detail::lock_request *<span class="keyword">&gt;</span>(batchread[0].data());</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160; </div>
<div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;          <span class="comment">// Skip all completed lock requests or not mentioning any of my entities</span></div>
<div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;          <span class="keywordflow">for</span>(; record &gt;= firstrecord; record_offset -= <span class="keyword">sizeof</span>(atomic_append_detail::lock_request), --record)</div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;          {</div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;            <span class="comment">// If a completed lock request, skip</span></div>
<div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;            <span class="keywordflow">if</span>(!record-&gt;hash &amp;&amp; (record-&gt;unique_id == 0u))</div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;            {</div>
<div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;              <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;            }</div>
<div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;            <span class="comment">// If record hash doesn&#39;t match contents it&#39;s a torn read, reload</span></div>
<div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;            <span class="keywordflow">if</span>(!_skip_hashing)</div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;            {</div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;              <span class="keywordflow">if</span>(record-&gt;hash != QUICKCPPLIB_NAMESPACE::algorithm::hash::fast_hash::hash((<span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span><span class="keywordtype">char</span> *<span class="keyword">&gt;</span>(record)) + 16, <span class="keyword">sizeof</span>(atomic_append_detail::lock_request) - 16))</div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;              {</div>
<div class="line"><a name="l00396"></a><span class="lineno">  396</span>&#160;                <span class="keywordflow">goto</span> reload;</div>
<div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;              }</div>
<div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;            }</div>
<div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160; </div>
<div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;            <span class="comment">// Does this record lock anything I am locking?</span></div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;            <span class="keywordflow">for</span>(<span class="keyword">const</span> <span class="keyword">auto</span> &amp;entity : out.entities)</div>
<div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;            {</div>
<div class="line"><a name="l00403"></a><span class="lineno">  403</span>&#160;              <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> n = 0; n &lt; record-&gt;items; n++)</div>
<div class="line"><a name="l00404"></a><span class="lineno">  404</span>&#160;              {</div>
<div class="line"><a name="l00405"></a><span class="lineno">  405</span>&#160;                <span class="keywordflow">if</span>(record-&gt;entities[n].value == entity.value)</div>
<div class="line"><a name="l00406"></a><span class="lineno">  406</span>&#160;                {</div>
<div class="line"><a name="l00407"></a><span class="lineno">  407</span>&#160;                  <span class="comment">// Is the lock I want exclusive or the lock he wants exclusive?</span></div>
<div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;                  <span class="comment">// If so, need to block</span></div>
<div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;                  <span class="keywordflow">if</span>((record-&gt;entities[n].exclusive != 0u) || (entity.exclusive != 0u))</div>
<div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;                  {</div>
<div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;                    <span class="keywordflow">goto</span> beginwait;</div>
<div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160;                  }</div>
<div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;                }</div>
<div class="line"><a name="l00414"></a><span class="lineno">  414</span>&#160;              }</div>
<div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;            }</div>
<div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;          }</div>
<div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;          <span class="comment">// None of this batch of records has anything to do with my request, so keep going</span></div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;          <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160; </div>
<div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;        beginwait:</div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;          <span class="comment">// Sleep until this record is freed using a shared lock</span></div>
<div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;          <span class="comment">// on the record in our way. Note there is a race here</span></div>
<div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;          <span class="comment">// between when the lock requester writes the lock</span></div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;          <span class="comment">// request and when he takes an exclusive lock on it,</span></div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;          <span class="comment">// so if our shared lock succeeds we need to immediately</span></div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;          <span class="comment">// unlock and retry based on the data.</span></div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;          std::this_thread::yield();</div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;          <span class="keywordflow">if</span>(!spin_not_sleep)</div>
<div class="line"><a name="l00429"></a><span class="lineno">  429</span>&#160;          {</div>
<div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;            deadline nd;</div>
<div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;            <span class="keywordflow">if</span>(d)</div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;            {</div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;              <span class="keywordflow">if</span>((d).steady)</div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;              {</div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;                std::chrono::nanoseconds ns = std::chrono::duration_cast&lt;std::chrono::nanoseconds&gt;((began_steady + std::chrono::nanoseconds((d).nsecs)) - std::chrono::steady_clock::now());</div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;                <span class="keywordflow">if</span>(ns.count() &lt; 0)</div>
<div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;                {</div>
<div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;                  (nd).nsecs = 0;</div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;                }</div>
<div class="line"><a name="l00440"></a><span class="lineno">  440</span>&#160;                <span class="keywordflow">else</span></div>
<div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;                {</div>
<div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;                  (nd).nsecs = ns.count();</div>
<div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;                }</div>
<div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;              }</div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;              <span class="keywordflow">else</span></div>
<div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;              {</div>
<div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;                (nd) = (d);</div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;              }</div>
<div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;            }</div>
<div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160;            <span class="keyword">auto</span> lock_offset = record_offset;</div>
<div class="line"><a name="l00451"></a><span class="lineno">  451</span>&#160;            <span class="comment">// Set the top bit to use the shadow lock space on Windows</span></div>
<div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;            lock_offset |= (1ULL &lt;&lt; 63U);</div>
<div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160;            OUTCOME_TRYV(_h.<a class="code" href="classllfio__v2__xxx_1_1lockable__io__handle.html#a0ece4f0a48e1e67debc438a9742a1f4c">lock_file_range</a>(lock_offset, <span class="keyword">sizeof</span>(*record), <a class="code" href="namespacellfio__v2__xxx.html#ae79486289ff1386b26d1ce60bb797d33a9e81e7b963c71363e2fb3eefcfecfc0e">lock_kind::shared</a>, nd));</div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;          }</div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;          <span class="comment">// Make sure we haven&#39;t timed out during this wait</span></div>
<div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;          <span class="keywordflow">if</span>(d)</div>
<div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;          {</div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;            <span class="keywordflow">if</span>((d).steady)</div>
<div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160;            {</div>
<div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;              <span class="keywordflow">if</span>(std::chrono::steady_clock::now() &gt;= (began_steady + std::chrono::nanoseconds((d).nsecs)))</div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;              {</div>
<div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;                <span class="keywordflow">return</span> errc::timed_out;</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;              }</div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;            }</div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;            {</div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;              <span class="keywordflow">if</span>(std::chrono::system_clock::now() &gt;= end_utc)</div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;              {</div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;                <span class="keywordflow">return</span> errc::timed_out;</div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;              }</div>
<div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;            }</div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;          }</div>
<div class="line"><a name="l00473"></a><span class="lineno">  473</span>&#160;        } <span class="keywordflow">while</span>(record_offset &gt;= _header.first_known_good);</div>
<div class="line"><a name="l00474"></a><span class="lineno">  474</span>&#160;        <span class="keywordflow">return</span> success();</div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;      }</div>
</div><!-- fragment -->
</div>
</div>
<a id="a53cfcfafa373bdb5a4d16f325b95d700"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a53cfcfafa373bdb5a4d16f325b95d700">&#9670;&nbsp;</a></span>fs_mutex_append()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static result&lt;<a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a>&gt; llfio_v2_xxx::algorithm::shared_fs_mutex::atomic_append::fs_mutex_append </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classllfio__v2__xxx_1_1path__handle.html">path_handle</a> &amp;&#160;</td>
          <td class="paramname"><em>base</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classllfio__v2__xxx_1_1path__view.html">path_view</a>&#160;</td>
          <td class="paramname"><em>lockfile</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>nfs_compatibility</em> = <code>false</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>skip_hashing</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Initialises a shared filing system mutex using the file at <em>lockfile</em> </p>
<dl class="section return"><dt>Returns</dt><dd>An implementation of shared_fs_mutex using the atomic_append algorithm. </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">base</td><td>Optional base for the path to the file. </td></tr>
    <tr><td class="paramname">lockfile</td><td>The path to the file to use for IPC. </td></tr>
    <tr><td class="paramname">nfs_compatibility</td><td>Make this true if the lockfile could be accessed by NFS. </td></tr>
    <tr><td class="paramname">skip_hashing</td><td>Some filing systems (typically the copy on write ones e.g. ZFS, btrfs) guarantee atomicity of updates and therefore torn writes are never observed by readers. For these, hashing can be safely disabled. </td></tr>
  </table>
  </dd>
</dl>
<dl class="todo"><dt><b><a class="el" href="todo.html#_todo000007">Todo:</a></b></dt><dd>fs_mutex_append needs to check if file still exists after lock is granted, awaiting path fetching. </dd></dl>
<div class="fragment"><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;      {</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;        LLFIO_LOG_FUNCTION_CALL(0);</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;        OUTCOME_TRY(<span class="keyword">auto</span> &amp;&amp;ret, <a class="code" href="classllfio__v2__xxx_1_1file__handle.html#a09e6b3e9806b328a687a55e955b885a3">file_handle::file</a>(base, lockfile, <a class="code" href="classllfio__v2__xxx_1_1handle.html#aa3930273a2d4cabbac309e0b75701dcaaefb2a684e4afb7d55e6147fbe5a332ee">file_handle::mode::write</a>, <a class="code" href="classllfio__v2__xxx_1_1handle.html#af0b352d0f273ba6fa70c178b2c2fee42a8f0339e854eb5321306a443ce9199e1d">file_handle::creation::if_needed</a>, <a class="code" href="classllfio__v2__xxx_1_1handle.html#aecd3a7db6cee3aec07d32fe6f99e6852ad5197d93c063a2b1e22d1630a39b7aef">file_handle::caching::temporary</a>));</div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;        atomic_append_detail::header header;</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;        <span class="comment">// Lock the entire header for exclusive access</span></div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;        <span class="keyword">auto</span> lockresult = ret.lock_file_range(0, <span class="keyword">sizeof</span>(header), <a class="code" href="namespacellfio__v2__xxx.html#ae79486289ff1386b26d1ce60bb797d33aa4293995cfbfa9ce60ce71ade2ff75f7">lock_kind::exclusive</a>, std::chrono::seconds(0));<span class="comment"></span></div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;<span class="comment">        //! \todo fs_mutex_append needs to check if file still exists after lock is granted, awaiting path fetching.</span></div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;<span class="comment"></span>        <span class="keywordflow">if</span>(lockresult.has_error())</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;        {</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;          <span class="keywordflow">if</span>(lockresult.error() != errc::timed_out)</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;          {</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;            <span class="keywordflow">return</span> std::move(lockresult).error();</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;          }</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;          <span class="comment">// Somebody else is also using this file</span></div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;        }</div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;        <span class="keywordflow">else</span></div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;        {</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;          <span class="comment">// I am the first person to be using this (stale?) file, so write a new header and truncate</span></div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;          OUTCOME_TRYV(ret.truncate(<span class="keyword">sizeof</span>(header)));</div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;          memset(&amp;header, 0, <span class="keyword">sizeof</span>(header));</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;          header.time_offset = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;          header.first_known_good = <span class="keyword">sizeof</span>(header);</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;          header.first_after_hole_punch = <span class="keyword">sizeof</span>(header);</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;          <span class="keywordflow">if</span>(!skip_hashing)</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;          {</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;            header.hash = QUICKCPPLIB_NAMESPACE::algorithm::hash::fast_hash::hash((<span class="keyword">reinterpret_cast&lt;</span><span class="keywordtype">char</span> *<span class="keyword">&gt;</span>(&amp;header)) + 16, <span class="keyword">sizeof</span>(header) - 16);</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;          }</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;          OUTCOME_TRYV(ret.write(0, {{reinterpret_cast&lt;byte *&gt;(&amp;header), sizeof(header)}}));</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;        }</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;        <span class="comment">// Open a shared lock on last byte in header to prevent other users zomping the file</span></div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;        OUTCOME_TRY(<span class="keyword">auto</span> &amp;&amp;guard, ret.lock_file_range(<span class="keyword">sizeof</span>(header) - 1, 1, <a class="code" href="namespacellfio__v2__xxx.html#ae79486289ff1386b26d1ce60bb797d33a9e81e7b963c71363e2fb3eefcfecfc0e">lock_kind::shared</a>));</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;        <span class="comment">// Unlock any exclusive lock I gained earlier now</span></div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;        <span class="keywordflow">if</span>(lockresult)</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;        {</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;          lockresult.value().unlock();</div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;        }</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;        <span class="comment">// The constructor will read and cache the header</span></div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;        <span class="keywordflow">return</span> atomic_append(std::move(ret), std::move(guard), nfs_compatibility, skip_hashing);</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;      }</div>
</div><!-- fragment -->
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>include/llfio/v2.0/algorithm/shared_fs_mutex/<a class="el" href="atomic__append_8hpp.html">atomic_append.hpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<div class="ttc" id="aclassllfio__v2__xxx_1_1handle_html_a101620e9fff0c0e8c346af0e9de58b6a"><div class="ttname"><a href="classllfio__v2__xxx_1_1handle.html#a101620e9fff0c0e8c346af0e9de58b6a">llfio_v2_xxx::handle::set_append_only</a></div><div class="ttdeci">virtual result&lt; void &gt; set_append_only(bool enable) noexcept</div><div class="ttdoc">EXTENSION: Changes whether this handle is append only or not.</div></div>
<div class="ttc" id="aclassllfio__v2__xxx_1_1io__handle_html_a7848ef15e774eacec7e4446a8c365a3d"><div class="ttname"><a href="classllfio__v2__xxx_1_1io__handle.html#a7848ef15e774eacec7e4446a8c365a3d">llfio_v2_xxx::io_handle::write</a></div><div class="ttdeci">io_result&lt; const_buffers_type &gt; write(io_request&lt; const_buffers_type &gt; reqs, deadline d=deadline()) noexcept</div><div class="ttdoc">Write data to the open handle, preferentially using any i/o multiplexer set over the virtually overri...</div><div class="ttdef"><b>Definition:</b> io_handle.hpp:325</div></div>
<div class="ttc" id="anamespacellfio__v2__xxx_html_ae79486289ff1386b26d1ce60bb797d33aa4293995cfbfa9ce60ce71ade2ff75f7"><div class="ttname"><a href="namespacellfio__v2__xxx.html#ae79486289ff1386b26d1ce60bb797d33aa4293995cfbfa9ce60ce71ade2ff75f7">llfio_v2_xxx::lock_kind::exclusive</a></div><div class="ttdeci">@ exclusive</div><div class="ttdoc">Exclude those requesting any kind of lock on the same inode.</div></div>
<div class="ttc" id="aclassllfio__v2__xxx_1_1lockable__io__handle_html_a0ece4f0a48e1e67debc438a9742a1f4c"><div class="ttname"><a href="classllfio__v2__xxx_1_1lockable__io__handle.html#a0ece4f0a48e1e67debc438a9742a1f4c">llfio_v2_xxx::lockable_io_handle::lock_file_range</a></div><div class="ttdeci">virtual result&lt; extent_guard &gt; lock_file_range(extent_type offset, extent_type bytes, lock_kind kind, deadline d=deadline()) noexcept</div><div class="ttdoc">EXTENSION: Tries to lock the range of bytes specified for shared or exclusive access....</div></div>
<div class="ttc" id="aclassllfio__v2__xxx_1_1file__handle_html_a7991af58283025b80a7225866643f0b4"><div class="ttname"><a href="classllfio__v2__xxx_1_1file__handle.html#a7991af58283025b80a7225866643f0b4">llfio_v2_xxx::file_handle::maximum_extent</a></div><div class="ttdeci">virtual result&lt; extent_type &gt; maximum_extent() const noexcept</div></div>
<div class="ttc" id="aclassllfio__v2__xxx_1_1handle_html_af0b352d0f273ba6fa70c178b2c2fee42a8f0339e854eb5321306a443ce9199e1d"><div class="ttname"><a href="classllfio__v2__xxx_1_1handle.html#af0b352d0f273ba6fa70c178b2c2fee42a8f0339e854eb5321306a443ce9199e1d">llfio_v2_xxx::handle::creation::if_needed</a></div><div class="ttdeci">@ if_needed</div><div class="ttdoc">If filesystem entry exists that is used, else one is created.</div></div>
<div class="ttc" id="anamespacellfio__v2__xxx_html_ae79486289ff1386b26d1ce60bb797d33a9e81e7b963c71363e2fb3eefcfecfc0e"><div class="ttname"><a href="namespacellfio__v2__xxx.html#ae79486289ff1386b26d1ce60bb797d33a9e81e7b963c71363e2fb3eefcfecfc0e">llfio_v2_xxx::lock_kind::shared</a></div><div class="ttdeci">@ shared</div><div class="ttdoc">Exclude only those requesting an exclusive lock on the same inode.</div></div>
<div class="ttc" id="aclassllfio__v2__xxx_1_1file__handle_html_a09e6b3e9806b328a687a55e955b885a3"><div class="ttname"><a href="classllfio__v2__xxx_1_1file__handle.html#a09e6b3e9806b328a687a55e955b885a3">llfio_v2_xxx::file_handle::file</a></div><div class="ttdeci">static result&lt; file_handle &gt; file(const path_handle &amp;base, path_view_type path, mode _mode=mode::read, creation _creation=creation::open_existing, caching _caching=caching::all, flag flags=flag::none) noexcept</div></div>
<div class="ttc" id="aclassllfio__v2__xxx_1_1io__handle_html_ae04ada27942187f03b59044cd1328f49"><div class="ttname"><a href="classllfio__v2__xxx_1_1io__handle.html#ae04ada27942187f03b59044cd1328f49">llfio_v2_xxx::io_handle::read</a></div><div class="ttdeci">io_result&lt; buffers_type &gt; read(io_request&lt; buffers_type &gt; reqs, deadline d=deadline()) noexcept</div><div class="ttdoc">Read data from the open handle, preferentially using any i/o multiplexer set over the virtually overr...</div><div class="ttdef"><b>Definition:</b> io_handle.hpp:283</div></div>
<div class="ttc" id="aclassllfio__v2__xxx_1_1handle_html_aecd3a7db6cee3aec07d32fe6f99e6852ad5197d93c063a2b1e22d1630a39b7aef"><div class="ttname"><a href="classllfio__v2__xxx_1_1handle.html#aecd3a7db6cee3aec07d32fe6f99e6852ad5197d93c063a2b1e22d1630a39b7aef">llfio_v2_xxx::handle::caching::temporary</a></div><div class="ttdeci">@ temporary</div><div class="ttdoc">Cache reads and writes of data and metadata so they complete immediately, only sending any updates to...</div></div>
<div class="ttc" id="aclassllfio__v2__xxx_1_1handle_html_aa3930273a2d4cabbac309e0b75701dcaaefb2a684e4afb7d55e6147fbe5a332ee"><div class="ttname"><a href="classllfio__v2__xxx_1_1handle.html#aa3930273a2d4cabbac309e0b75701dcaaefb2a684e4afb7d55e6147fbe5a332ee">llfio_v2_xxx::handle::mode::write</a></div><div class="ttdeci">@ write</div><div class="ttdoc">Ability to read and write (READ_CONTROL|FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA|FILE_WRITE_D...</div></div>
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="namespacellfio__v2__xxx.html">llfio_v2_xxx</a></li><li class="navelem"><a class="el" href="namespacellfio__v2__xxx_1_1algorithm.html">algorithm</a></li><li class="navelem"><a class="el" href="namespacellfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex.html">shared_fs_mutex</a></li><li class="navelem"><a class="el" href="classllfio__v2__xxx_1_1algorithm_1_1shared__fs__mutex_1_1atomic__append.html">atomic_append</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li>
  </ul>
</div>
</body>
</html>