[ { "psig_desc": [ "Psig_attribute", { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.text" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " Atomic references.\n\n See {{!examples} the examples} below.\n See 'Memory model: The hard bits' chapter in the manual.\n\n @since 4.12\n", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 18, "pos_bol": 1233, "pos_cnum": 1233 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 24, "pos_bol": 1373, "pos_cnum": 1375 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 18, "pos_bol": 1233, "pos_cnum": 1233 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 24, "pos_bol": 1373, "pos_cnum": 1375 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 18, "pos_bol": 1233, "pos_cnum": 1233 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 24, "pos_bol": 1373, "pos_cnum": 1375 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 18, "pos_bol": 1233, "pos_cnum": 1233 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 24, "pos_bol": 1373, "pos_cnum": 1375 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 18, "pos_bol": 1233, "pos_cnum": 1233 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 24, "pos_bol": 1373, "pos_cnum": 1375 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_type", [ "Recursive" ], [ { "ptype_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 27, "pos_bol": 1439, "pos_cnum": 1448 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 27, "pos_bol": 1439, "pos_cnum": 1449 }, "loc_ghost": false }, "txt2": "t" }, "ptype_params": [ [ { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 27, "pos_bol": 1439, "pos_cnum": 1445 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 27, "pos_bol": 1439, "pos_cnum": 1447 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, [ [ "NoVariance" ], [ "Injective" ] ] ] ], "ptype_cstrs": [], "ptype_kind": [ "Ptype_abstract" ], "ptype_private": [ "Public" ], "ptype_manifest": null, "ptype_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " An atomic (mutable) reference to a value of type ['a]. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 26, "pos_bol": 1377, "pos_cnum": 1377 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 26, "pos_bol": 1377, "pos_cnum": 1438 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 26, "pos_bol": 1377, "pos_cnum": 1377 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 26, "pos_bol": 1377, "pos_cnum": 1438 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 26, "pos_bol": 1377, "pos_cnum": 1377 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 26, "pos_bol": 1377, "pos_cnum": 1438 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 26, "pos_bol": 1377, "pos_cnum": 1377 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 26, "pos_bol": 1377, "pos_cnum": 1438 }, "loc_ghost": false } } ], "ptype_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 27, "pos_bol": 1439, "pos_cnum": 1439 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 27, "pos_bol": 1439, "pos_cnum": 1449 }, "loc_ghost": false } } ] ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 27, "pos_bol": 1439, "pos_cnum": 1439 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 27, "pos_bol": 1439, "pos_cnum": 1449 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1490 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1494 }, "loc_ghost": false }, "txt2": "make" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1497 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1499 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1503 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1505 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1503 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1507 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1497 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1507 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " Create an atomic reference. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 29, "pos_bol": 1451, "pos_cnum": 1451 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 29, "pos_bol": 1451, "pos_cnum": 1485 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 29, "pos_bol": 1451, "pos_cnum": 1451 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 29, "pos_bol": 1451, "pos_cnum": 1485 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 29, "pos_bol": 1451, "pos_cnum": 1451 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 29, "pos_bol": 1451, "pos_cnum": 1485 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 29, "pos_bol": 1451, "pos_cnum": 1451 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 29, "pos_bol": 1451, "pos_cnum": 1485 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1486 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1507 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1486 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 30, "pos_bol": 1486, "pos_cnum": 1507 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2201 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2215 }, "loc_ghost": false }, "txt2": "make_contended" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2218 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2220 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2224 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2226 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2224 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2228 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2218 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2228 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " Create an atomic reference that is alone on a cache line. It occupies 4-16x\n the memory of one allocated with [make v].\n\n The primary purpose is to prevent false-sharing and the resulting\n performance degradation. When a CPU performs an atomic operation, it\n temporarily takes ownership of an entire cache line that contains the\n atomic reference. If multiple atomic references share the same cache line,\n modifying these disjoint memory regions simultaneously becomes impossible,\n which can create a bottleneck. Hence, as a general guideline, if an atomic\n reference is experiencing contention, assigning it its own cache line may\n enhance performance. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 32, "pos_bol": 1509, "pos_cnum": 1509 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 42, "pos_bol": 2169, "pos_cnum": 2196 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 32, "pos_bol": 1509, "pos_cnum": 1509 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 42, "pos_bol": 2169, "pos_cnum": 2196 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 32, "pos_bol": 1509, "pos_cnum": 1509 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 42, "pos_bol": 2169, "pos_cnum": 2196 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 32, "pos_bol": 1509, "pos_cnum": 1509 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 42, "pos_bol": 2169, "pos_cnum": 2196 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2197 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2228 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2197 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 43, "pos_bol": 2197, "pos_cnum": 2228 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2288 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2291 }, "loc_ghost": false }, "txt2": "get" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2294 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2296 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2294 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2298 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2302 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2304 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2294 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2304 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " Get the current value of the atomic reference. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 45, "pos_bol": 2230, "pos_cnum": 2230 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 45, "pos_bol": 2230, "pos_cnum": 2283 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 45, "pos_bol": 2230, "pos_cnum": 2230 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 45, "pos_bol": 2230, "pos_cnum": 2283 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 45, "pos_bol": 2230, "pos_cnum": 2230 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 45, "pos_bol": 2230, "pos_cnum": 2283 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 45, "pos_bol": 2230, "pos_cnum": 2230 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 45, "pos_bol": 2230, "pos_cnum": 2283 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2284 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2304 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2284 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 46, "pos_bol": 2284, "pos_cnum": 2304 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2359 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2362 }, "loc_ghost": false }, "txt2": "set" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2365 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2367 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2365 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2369 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2373 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2375 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_constr", "unit", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2379 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2383 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2373 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2383 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2365 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2383 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " Set a new value for the atomic reference. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 48, "pos_bol": 2306, "pos_cnum": 2306 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 48, "pos_bol": 2306, "pos_cnum": 2354 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 48, "pos_bol": 2306, "pos_cnum": 2306 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 48, "pos_bol": 2306, "pos_cnum": 2354 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 48, "pos_bol": 2306, "pos_cnum": 2306 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 48, "pos_bol": 2306, "pos_cnum": 2354 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 48, "pos_bol": 2306, "pos_cnum": 2306 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 48, "pos_bol": 2306, "pos_cnum": 2354 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2355 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2383 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2355 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 49, "pos_bol": 2355, "pos_cnum": 2383 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2468 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2476 }, "loc_ghost": false }, "txt2": "exchange" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2479 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2481 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2479 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2483 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2487 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2489 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2493 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2495 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2487 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2495 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2479 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2495 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " Set a new value for the atomic reference, and return the current value. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 51, "pos_bol": 2385, "pos_cnum": 2385 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 51, "pos_bol": 2385, "pos_cnum": 2463 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 51, "pos_bol": 2385, "pos_cnum": 2385 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 51, "pos_bol": 2385, "pos_cnum": 2463 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 51, "pos_bol": 2385, "pos_cnum": 2385 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 51, "pos_bol": 2385, "pos_cnum": 2463 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 51, "pos_bol": 2385, "pos_cnum": 2385 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 51, "pos_bol": 2385, "pos_cnum": 2463 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2464 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2495 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2464 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 52, "pos_bol": 2464, "pos_cnum": 2495 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2776 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2791 }, "loc_ghost": false }, "txt2": "compare_and_set" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2794 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2796 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2794 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2798 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2802 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2804 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_var", "a" ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2808 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2810 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_constr", "bool", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2814 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2818 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2808 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2818 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2802 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2818 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2794 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2818 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " [compare_and_set r seen v] sets the new value of [r] to [v] only\n if its current value is physically equal to [seen] -- the\n comparison and the set occur atomically. Returns [true] if the\n comparison succeeded (so the set happened) and [false]\n otherwise. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 54, "pos_bol": 2497, "pos_cnum": 2497 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 58, "pos_bol": 2754, "pos_cnum": 2771 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 54, "pos_bol": 2497, "pos_cnum": 2497 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 58, "pos_bol": 2754, "pos_cnum": 2771 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 54, "pos_bol": 2497, "pos_cnum": 2497 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 58, "pos_bol": 2754, "pos_cnum": 2771 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 54, "pos_bol": 2497, "pos_cnum": 2497 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 58, "pos_bol": 2754, "pos_cnum": 2771 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2772 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2818 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2772 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 59, "pos_bol": 2772, "pos_cnum": 2818 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2956 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2969 }, "loc_ghost": false }, "txt2": "fetch_and_add" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_constr", "int", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2972 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2975 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2972 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2977 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_constr", "int", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2981 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2984 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_constr", "int", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2988 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2991 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2981 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2991 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2972 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2991 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " [fetch_and_add r n] atomically increments the value of [r] by [n],\n and returns the current value (before the increment). ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 61, "pos_bol": 2820, "pos_cnum": 2820 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 62, "pos_bol": 2891, "pos_cnum": 2951 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 61, "pos_bol": 2820, "pos_cnum": 2820 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 62, "pos_bol": 2891, "pos_cnum": 2951 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 61, "pos_bol": 2820, "pos_cnum": 2820 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 62, "pos_bol": 2891, "pos_cnum": 2951 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 61, "pos_bol": 2820, "pos_cnum": 2820 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 62, "pos_bol": 2891, "pos_cnum": 2951 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2952 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2991 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2952 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 63, "pos_bol": 2952, "pos_cnum": 2991 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3060 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3064 }, "loc_ghost": false }, "txt2": "incr" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_constr", "int", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3067 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3070 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3067 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3072 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_constr", "unit", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3076 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3080 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3067 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3080 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " [incr r] atomically increments the value of [r] by [1]. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 65, "pos_bol": 2993, "pos_cnum": 2993 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 65, "pos_bol": 2993, "pos_cnum": 3055 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 65, "pos_bol": 2993, "pos_cnum": 2993 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 65, "pos_bol": 2993, "pos_cnum": 3055 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 65, "pos_bol": 2993, "pos_cnum": 2993 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 65, "pos_bol": 2993, "pos_cnum": 3055 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 65, "pos_bol": 2993, "pos_cnum": 2993 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 65, "pos_bol": 2993, "pos_cnum": 3055 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3056 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3080 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3056 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 66, "pos_bol": 3056, "pos_cnum": 3080 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_value", { "pval_name": { "loc2": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3149 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3153 }, "loc_ghost": false }, "txt2": "decr" }, "pval_type": { "ptyp_desc": [ "Ptyp_arrow", [ "Nolabel" ], { "ptyp_desc": [ "Ptyp_constr", "t", [ { "ptyp_desc": [ "Ptyp_constr", "int", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3156 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3159 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3156 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3161 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, { "ptyp_desc": [ "Ptyp_constr", "unit", [] ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3165 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3169 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] } ], "ptyp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3156 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3169 }, "loc_ghost": false }, "ptyp_loc_stack": [], "ptyp_attributes": [] }, "pval_prim": [], "pval_attributes": [ { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.doc" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " [decr r] atomically decrements the value of [r] by [1]. ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 68, "pos_bol": 3082, "pos_cnum": 3082 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 68, "pos_bol": 3082, "pos_cnum": 3144 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 68, "pos_bol": 3082, "pos_cnum": 3082 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 68, "pos_bol": 3082, "pos_cnum": 3144 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 68, "pos_bol": 3082, "pos_cnum": 3082 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 68, "pos_bol": 3082, "pos_cnum": 3144 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 68, "pos_bol": 3082, "pos_cnum": 3082 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 68, "pos_bol": 3082, "pos_cnum": 3144 }, "loc_ghost": false } } ], "pval_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3145 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3169 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3145 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 69, "pos_bol": 3145, "pos_cnum": 3169 }, "loc_ghost": false } }, { "psig_desc": [ "Psig_attribute", { "attr_name": { "loc2": { "loc_start": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_end": { "pos_fname": "_none_", "pos_lnum": 0, "pos_bol": 0, "pos_cnum": -1 }, "loc_ghost": true }, "txt2": "ocaml.text" }, "attr_payload": [ "PStr", [ { "pstr_desc": [ "Pstr_eval", { "pexp_desc": [ "Pexp_constant", [ "Pconst_string", " {1:examples Examples}\n\n {2 Basic Thread Coordination}\n\n A basic use case is to have global counters that are updated in a\n thread-safe way, for example to keep some sorts of metrics\n over IOs performed by the program. Another basic use case is to coordinate\n the termination of threads in a given program, for example when one thread\n finds an answer, or when the program is shut down by the user.\n\n Here, for example, we're going to try to find a number whose hash\n satisfies a basic property. To do that, we'll run multiple threads which\n will try random numbers until they find one that works.\n\n Of course the output below is a sample run and will change every time\n the program is run.\n\n {[\n (* use for termination *)\n let stop_all_threads = Atomic.make false\n\n (* total number of individual attempts to find a number *)\n let num_attempts = Atomic.make 0\n\n (* find a number that satisfies [p], by... trying random numbers\n until one fits. *)\n let find_number_where (p:int -> bool) =\n let rand = Random.State.make_self_init() in\n while not (Atomic.get stop_all_threads) do\n\n let n = Random.State.full_int rand max_int in\n ignore (Atomic.fetch_and_add num_attempts 1 : int);\n\n if p (Hashtbl.hash n) then (\n Printf.printf \"found %d (hash=%d)\\n%!\" n (Hashtbl.hash n);\n Atomic.set stop_all_threads true; (* signal all threads to stop *)\n )\n done;;\n\n\n (* run multiple domains to search for a [n] where [hash n <= 100] *)\n let () =\n let criterion n = n <= 100 in\n let threads =\n Array.init 8\n (fun _ -> Domain.spawn (fun () -> find_number_where criterion))\n in\n Array.iter Domain.join threads;\n Printf.printf \"total number of attempts: %d\\n%!\"\n (Atomic.get num_attempts) ;;\n\n - : unit = ()\n found 1651745641680046833 (hash=33)\n total number of attempts: 30230350\n ]}\n\n {2 Treiber Stack}\n\n Another example is a basic\n {{: https://en.wikipedia.org/wiki/Treiber_stack} Treiber stack}\n (a thread-safe stack) that can be safely shared between threads.\n\n Note how both [push] and [pop] are recursive, because they attempt to\n swap the new stack (with one more, or one fewer, element) with the old\n stack.\n This is optimistic concurrency: each iteration of, say, [push stack x]\n gets the old stack [l], and hopes that by the time it tries to replace\n [l] with [x::l], nobody else has had time to modify the list. If the\n [compare_and_set] fails it means we were too optimistic, and must try\n again.\n\n {[\n type 'a stack = 'a list Atomic.t\n\n let rec push (stack: _ stack) elt : unit =\n let cur = Atomic.get stack in\n let success = Atomic.compare_and_set stack cur (elt :: cur) in\n if not success then\n push stack elt\n\n let rec pop (stack: _ stack) : _ option =\n let cur = Atomic.get stack in\n match cur with\n | [] -> None\n | x :: tail ->\n let success = Atomic.compare_and_set stack cur tail in\n if success then Some x\n else pop stack\n\n # let st = Atomic.make []\n # push st 1\n - : unit = ()\n # push st 2\n - : unit = ()\n # pop st\n - : int option = Some 2\n # pop st\n - : int option = Some 1\n # pop st\n - : int option = None\n ]}\n ", { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 71, "pos_bol": 3171, "pos_cnum": 3171 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 172, "pos_bol": 6522, "pos_cnum": 6526 }, "loc_ghost": false }, null ] ], "pexp_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 71, "pos_bol": 3171, "pos_cnum": 3171 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 172, "pos_bol": 6522, "pos_cnum": 6526 }, "loc_ghost": false }, "pexp_loc_stack": [], "pexp_attributes": [] }, [] ], "pstr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 71, "pos_bol": 3171, "pos_cnum": 3171 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 172, "pos_bol": 6522, "pos_cnum": 6526 }, "loc_ghost": false } } ] ], "attr_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 71, "pos_bol": 3171, "pos_cnum": 3171 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 172, "pos_bol": 6522, "pos_cnum": 6526 }, "loc_ghost": false } } ], "psig_loc": { "loc_start": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 71, "pos_bol": 3171, "pos_cnum": 3171 }, "loc_end": { "pos_fname": "./stdlib/atomic.mli", "pos_lnum": 172, "pos_bol": 6522, "pos_cnum": 6526 }, "loc_ghost": false } } ]