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 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201
|
[/
(C) Copyright 2007-8 Anthony Williams.
(C) Copyright 2011-12 Vicente J. Botet Escriba.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
]
[section:mutex_concepts Mutex Concepts]
A mutex object facilitates protection against data races and allows thread-safe synchronization of data between threads. A thread
obtains ownership of a mutex object by calling one of the lock functions and relinquishes ownership by calling the corresponding
unlock function. Mutexes may be either recursive or non-recursive, and may grant simultaneous ownership to one or many
threads. __boost_thread__ supplies recursive and non-recursive mutexes with exclusive ownership semantics, along with a shared
ownership (multiple-reader / single-writer) mutex.
__boost_thread__ supports four basic concepts for lockable objects: __lockable_concept_type__, __timed_lockable_concept_type__,
__shared_lockable_concept_type__ and __upgrade_lockable_concept_type__. Each mutex type implements one or more of these concepts, as
do the various lock types.
[section:basic_lockable `BasicLockable` Concept]
// #include <boost/thread/lockable_concepts.hpp>
namespace boost
{
template<typename L>
class BasicLockable; // EXTENSION
}
The __BasicLockable concept models exclusive ownership.
A type `L` meets the __BasicLockable requirements if the following expressions are well-formed and have the specified semantics (`m` denotes a value of type `L`):
* `m.__lock();`
* `m.__unlock();`
Lock ownership acquired through a call to __lock_ref__ must be released through a call to __unlock_ref__.
[section:lock `m.lock();`]
[variablelist
[[Requires:] [The calling thread doesn't owns the mutex if the mutex is not recursive.]]
[[Effects:] [The current thread blocks until ownership can be obtained for the current thread.]]
[[Synchronization:] [Prior `unlock()` operations on the same object synchronizes with this operation. ]]
[[Postcondition:] [The current thread owns `m`.]]
[[Return type:] [`void`.]]
[[Throws:] [__lock_error__ if an error occurs.]]
[[Error Conditions:] [
[*operation_not_permitted]: if the thread does not have the privilege to perform the operation.
[*resource_deadlock_would_occur]: if the implementation detects that a deadlock would occur.
[*device_or_resource_busy]: if the mutex is already locked and blocking is not possible.
]]
[[Thread safety:] [If an exception is thrown then a lock shall not have been acquired for the current thread.]]
]
[endsect]
[section:unlock `m.unlock();`]
[variablelist
[[Requires:] [The current thread owns `m`.]]
[[Synchronization:] [This operation synchronizes with subsequent lock operations that obtain ownership on the same object.]]
[[Effects:] [Releases a lock on `m` by the current thread.]]
[[Return type:] [`void`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:is_basic_lockable `is_basic_lockable` trait -- EXTENSION]
// #include <boost/thread/lockable_traits.hpp>
namespace boost
{
namespace sync
{
template<typename L>
class is_basic_lockable;// EXTENSION
}
}
Some of the algorithms on mutexes use this trait via SFINAE.
This trait is true_type if the parameter L meets the __Lockable requirements.
[warning If BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES is defined you will need to specialize this traits for the models of BasicLockable you could build.]
[endsect]
[endsect]
[section:lockable `Lockable` Concept]
// #include <boost/thread/lockable_concepts.hpp>
namespace boost
{
template<typename L>
class Lockable;
}
A type `L` meets the __Lockable requirements if it meets the __BasicLockable requirements and the following expressions are well-formed and have the specified semantics (`m` denotes a value of type `L`):
* `m.__try_lock()`
Lock ownership acquired through a call to __try_lock_ref__ must be released through a call to __unlock_ref__.
[section:try_lock `m.try_lock()`]
[variablelist
[[Requires:] [The calling thread doesn't owns the mutex if the mutex is not recursive.]]
[[Effects:] [Attempt to obtain ownership for the current thread without blocking.]]
[[Synchronization:] [If `try_lock()` returns true, prior `unlock()` operations on the same object synchronize with this operation.]]
[[Note:] [Since `lock()` does not synchronize with a failed subsequent
`try_lock()`, the visibility rules are weak enough that little would be known about the state after a
failure, even in the absence of spurious failures.]]
[[Return type:] [`bool`.]]
[[Returns:] [`true` if ownership was obtained for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread owns the `m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:is_lockable `is_lockable` trait -- EXTENSION]
// #include <boost/thread/lockable_traits.hpp>
namespace boost
{
namespace sync
{
template<typename L>
class is_lockable;// EXTENSION
}
}
Some of the algorithms on mutexes use this trait via SFINAE.
This trait is true_type if the parameter L meets the __Lockable requirements.
[warning If BOOST_THREAD_NO_AUTO_DETECT_MUTEX_TYPES is defined you will need to specialize this traits for the models of Lockable you could build.]
[endsect]
[endsect]
[section:recursive Recursive Lockable Concept]
The user could require that the mutex passed to an algorithm is a recursive one. Whether a lockable is recursive or not can not be checked using template meta-programming. This is the motivation for the following trait.
[section:is_recursive_mutex_sur_parole `is_recursive_mutex_sur_parole` trait -- EXTENSION]
// #include <boost/thread/lockable_traits.hpp>
namespace boost
{
namespace sync
{
template<typename L>
class is_recursive_mutex_sur_parole: false_type; // EXTENSION
template<>
class is_recursive_mutex_sur_parole<recursive_mutex>: true_type; // EXTENSION
template<>
class is_recursive_mutex_sur_parole<timed_recursive_mutex>: true_type; // EXTENSION
}
}
The trait `is_recursive_mutex_sur_parole` is `false_type` by default and is specialized for the provide `recursive_mutex` and `timed_recursive_mutex`.
It should be specialized by the user providing other model of recursive lockable.
[endsect]
[section:is_recursive_basic_lockable `is_recursive_basic_lockable` trait -- EXTENSION]
// #include <boost/thread/lockable_traits.hpp>
namespace boost
{
namespace sync
{
template<typename L>
class is_recursive_basic_lockable;// EXTENSION
}
}
This traits is true_type if is_basic_lockable and is_recursive_mutex_sur_parole.
[endsect]
[section:is_recursive_lockable `is_recursive_lockable` trait -- EXTENSION]
// #include <boost/thread/lockable_traits.hpp>
namespace boost
{
namespace sync
{
template<typename L>
class is_recursive_lockable;// EXTENSION
}
}
This traits is true_type if is_lockable and is_recursive_mutex_sur_parole.
[endsect]
[endsect]
[section:timed_lockable `TimedLockable` Concept]
// #include <boost/thread/lockable_concepts.hpp>
namespace boost
{
template<typename L>
class TimedLockable; // EXTENSION
}
The __timed_lockable_concept__ refines the __lockable_concept__ to add support for
timeouts when trying to acquire the lock.
A type `L` meets the __TimedLockable requirements if it meets the __Lockable requirements and the following expressions are well-formed and have the specified semantics.
[*Variables:]
* `m` denotes a value of type `L`,
* `rel_time` denotes a value of an instantiation of `chrono::duration`, and
* `abs_time` denotes a value of an instantiation of `chrono::time_point`:
[*Expressions:]
* `m.__try_lock_for(rel_time)`
* `m.__try_lock_until(abs_time)`
Lock ownership acquired through a call to __try_lock_for or __try_lock_until must be released through a call to __unlock.
[section:try_lock_until `m.try_lock_until(abs_time)`]
[variablelist
[[Requires:] [The calling thread doesn't owns the mutex if the mutex is not recursive.]]
[[Effects:] [Attempt to obtain ownership for the current thread. Blocks until ownership can be obtained, or the specified time is
reached. If the specified time has already passed, behaves as __try_lock_ref__.]]
[[Synchronization:] [If `try_lock_until()` returns true, prior `unlock()` operations on the same object synchronize with this operation.]]
[[Return type:] [`bool`.]]
[[Returns:] [`true` if ownership was obtained for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread owns `m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:try_lock_for `m.try_lock_for(rel_time)`]
[variablelist
[[Requires:] [The calling thread doesn't owns the mutex if the mutex is not recursive.]]
[[Effects:] [As-if `__try_lock_until(chrono::steady_clock::now() + rel_time)`.]]
[[Synchronization:] [If `try_lock_for()` returns true, prior `unlock()` operations on the same object synchronize with this operation.]]
]
[endsect]
[warning
DEPRECATED since 4.00. The following expressions were required on version 2, but are now deprecated.
Available only up to Boost 1.58.
Use instead __try_lock_for, __try_lock_until.
]
[*Variables:]
* `rel_time` denotes a value of an instantiation of an unspecified `DurationType` arithmetic compatible with `boost::system_time`, and
* `abs_time` denotes a value of an instantiation of `boost::system_time`:
[*Expressions:]
* `m.__timed_lock_duration(rel_time)`
* `m.__timed_lock(abs_time)`
Lock ownership acquired through a call to __timed_lock_ref__ must be released through a call to __unlock_ref__.
[section:timed_lock `m.timed_lock(abs_time)`]
[variablelist
[[Effects:] [Attempt to obtain ownership for the current thread. Blocks until ownership can be obtained, or the specified time is
reached. If the specified time has already passed, behaves as __try_lock_ref__.]]
[[Returns:] [`true` if ownership was obtained for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread owns `m`.]]
[[Throws:] [__lock_error__ if an error occurs.]]
]
[endsect]
[section:timed_lock_duration `m.timed_lock(rel_time)`]
[variablelist
[[Effects:] [As-if [timed_lock_ref_link
`timed_lock(boost::get_system_time()+rel_time)`].]]
]
[endsect]
[endsect]
[section:shared_lockable `SharedLockable` Concept -- C++14]
// #include <boost/thread/lockable_concepts.hpp>
namespace boost
{
template<typename L>
class SharedLockable; // C++14
}
The __shared_lockable_concept__ is a refinement of the __timed_lockable_concept__ that
allows for ['shared ownership] as well as ['exclusive ownership]. This is the
standard multiple-reader / single-write model: at most one thread can have
exclusive ownership, and if any thread does have exclusive ownership, no other threads
can have shared or exclusive ownership. Alternatively, many threads may have
shared ownership.
A type `L` meets the __SharedLockable requirements if it meets the __TimedLockable requirements and the following expressions are well-formed and have the specified semantics.
[*Variables:]
* `m` denotes a value of type `L`,
* `rel_time` denotes a value of an instantiation of `chrono::duration`, and
* `abs_time` denotes a value of an instantiation of `chrono::time_point`:
[*Expressions:]
* `m.__lock_shared();`
* `m.__try_lock_shared()`
* `m.__try_lock_shared_for(rel_time)`
* `m.__try_lock_shared_until(abs_time)`
* `m.__unlock_shared();`
Lock ownership acquired through a call to __lock_shared_ref__, __try_lock_shared_ref__, __try_lock_shared_for or __try_lock_shared_until must be released through a call to __unlock_shared_ref__.
[section:lock_shared `m.lock_shared()`]
[variablelist
[[Effects:] [The current thread blocks until shared ownership can be obtained for the current thread.]]
[[Postcondition:] [The current thread has shared ownership of `m`.]]
[[Throws:] [__lock_error__ if an error occurs.]]
]
[endsect]
[section:try_lock_shared `m.try_lock_shared()`]
[variablelist
[[Effects:] [Attempt to obtain shared ownership for the current thread without blocking.]]
[[Returns:] [`true` if shared ownership was obtained for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has shared ownership of `m`.]]
[[Throws:] [__lock_error__ if an error occurs.]]
]
[endsect]
[section:try_lock_shared_for `m.try_lock_shared_for(rel_time)`]
[variablelist
[[Effects:] [Attempt to obtain shared ownership for the current thread. Blocks until shared ownership can be obtained, or the
specified duration is elapsed. If the specified duration is already elapsed, behaves as __try_lock_shared_ref__.]]
[[Returns:] [`true` if shared ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has shared
ownership of `m`.]]
[[Throws:] [__lock_error__ if an error occurs.]]
]
[endsect]
[section:try_lock_shared_until `m.try_lock_shared_until(abs_time))`]
[variablelist
[[Effects:] [Attempt to obtain shared ownership for the current thread. Blocks until shared ownership can be obtained, or the
specified time is reached. If the specified time has already passed, behaves as __try_lock_shared_ref__.]]
[[Returns:] [`true` if shared ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has shared
ownership of `m`.]]
[[Throws:] [__lock_error__ if an error occurs.]]
]
[endsect]
[section:unlock_shared `m.unlock_shared()`]
[variablelist
[[Precondition:] [The current thread has shared ownership of `m`.]]
[[Effects:] [Releases shared ownership of `m` by the current thread.]]
[[Postcondition:] [The current thread no longer has shared ownership of `m`.]]
[[Throws:] [Nothing]]
]
[endsect]
[warning
DEPRECATED since 3.00. The following expressions were required on version 2, but are now deprecated.
Available only up to Boost 1.56.
Use instead __try_lock_shared_for, __try_lock_shared_until.
]
[*Variables:]
* `abs_time` denotes a value of an instantiation of `boost::system_time`:
[*Expressions:]
* `m.timed_lock_shared(abs_time);`
Lock ownership acquired through a call to __timed_lock_shared_ref__ must be released through a call to __unlock_shared_ref__.
[section:timed_lock_shared `m.timed_lock_shared(abs_time)`]
[variablelist
[[Effects:] [Attempt to obtain shared ownership for the current thread. Blocks until shared ownership can be obtained, or the
specified time is reached. If the specified time has already passed, behaves as __try_lock_shared_ref__.]]
[[Returns:] [`true` if shared ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has shared
ownership of `m`.]]
[[Throws:] [__lock_error__ if an error occurs.]]
]
[endsect]
[endsect]
[section:upgrade_lockable `UpgradeLockable` Concept -- EXTENSION]
// #include <boost/thread/lockable_concepts.hpp>
namespace boost
{
template<typename L>
class UpgradeLockable; // EXTENSION
}
The __upgrade_lockable_concept__ is a refinement of the __shared_lockable_concept__ that allows for ['upgradable ownership] as well
as ['shared ownership] and ['exclusive ownership]. This is an extension to the multiple-reader / single-write model provided by the
__shared_lockable_concept__: a single thread may have ['upgradable ownership] at the same time as others have ['shared
ownership]. The thread with ['upgradable ownership] may at any time attempt to upgrade that ownership to ['exclusive ownership]. If
no other threads have shared ownership, the upgrade is completed immediately, and the thread now has ['exclusive ownership], which
must be relinquished by a call to __unlock_ref__, just as if it had been acquired by a call to __lock_ref__.
If a thread with ['upgradable ownership] tries to upgrade whilst other threads have ['shared ownership], the attempt will fail and
the thread will block until ['exclusive ownership] can be acquired.
Ownership can also be ['downgraded] as well as ['upgraded]: exclusive ownership of an implementation of the
__upgrade_lockable_concept__ can be downgraded to upgradable ownership or shared ownership, and upgradable ownership can be
downgraded to plain shared ownership.
A type `L` meets the __UpgradeLockable requirements if it meets the __SharedLockable
requirements and the following expressions are well-formed and have the specified semantics.
[*Variables:]
* `m` denotes a value of type `L`,
* `rel_time` denotes a value of an instantiation of `chrono::duration`, and
* `abs_time` denotes a value of an instantiation of `chrono::time_point`:
[*Expressions:]
* `m.__lock_upgrade();`
* `m.__unlock_upgrade()`
* `m.__try_lock_upgrade()`
* `m.__try_lock_upgrade_for(rel_time)`
* `m.__try_lock_upgrade_until(abs_time)`
* `m.__unlock_and_lock_shared()`
* `m.__unlock_and_lock_upgrade();`
* `m.__unlock_upgrade_and_lock();`
* `m.__try_unlock_upgrade_and_lock()`
* `m.__try_unlock_upgrade_and_lock_for(rel_time)`
* `m.__try_unlock_upgrade_and_lock_until(abs_time)`
* `m.__unlock_upgrade_and_lock_shared();`
If `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION is defined the following expressions are also required:
* `m.__try_unlock_shared_and_lock();`
* `m.__try_unlock_shared_and_lock_for(rel_time);`
* `m.__try_unlock_shared_and_lock_until(abs_time);`
* `m.__try_unlock_shared_and_lock_upgrade();`
* `m.__try_unlock_shared_and_lock_upgrade_for(rel_time);`
* `m.__try_unlock_shared_and_lock_upgrade_until(abs_time);`
Lock ownership acquired through a call to __lock_upgrade_ref__ must be released through a call to __unlock_upgrade_ref__. If the
ownership type is changed through a call to one of the `unlock_xxx_and_lock_yyy()` functions, ownership must be released through a
call to the unlock function corresponding to the new level of ownership.
[section:lock_upgrade `m.lock_upgrade()`]
[variablelist
[[Precondition:] [The calling thread has no ownership of the mutex. ]]
[[Effects:] [The current thread blocks until upgrade ownership can be obtained for the current thread.]]
[[Postcondition:] [The current thread has upgrade ownership of `m`.]]
[[Synchronization:] [Prior `__unlock_upgrade()` operations on the same object synchronize with this operation.]]
[[Throws:] [__lock_error__ if an error occurs.]]
]
[endsect]
[section:unlock_upgrade `m.unlock_upgrade()`]
[variablelist
[[Precondition:] [The current thread has upgrade ownership of `m`.]]
[[Effects:] [Releases upgrade ownership of `m` by the current thread.]]
[[Postcondition:] [The current thread no longer has upgrade ownership of `m`.]]
[[Synchronization:] [This operation synchronizes with subsequent lock operations that obtain ownership on the same object.]]
[[Throws:] [Nothing]]
]
[endsect]
[section:try_lock_upgrade `m.try_lock_upgrade()`]
[variablelist
[[Precondition:] [The calling thread has no ownership of the mutex. ]]
[[Effects:] [Attempts to obtain upgrade ownership of the mutex for the calling thread without blocking. If upgrade ownership is not obtained, there is no effect and try_lock_upgrade() immediately returns.]]
[[Returns:] [`true` if upgrade ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has upgrade ownership of `m`.]]
[[Synchronization:] [If `__try_lock_upgrade()` returns true, prior `__unlock_upgrade()` operations on the same object synchronize with this operation.]]
[[Throws:] [Nothing]]
]
[endsect]
[section:try_lock_upgrade_for `m.try_lock_upgrade_for(rel_time)`]
[variablelist
[[Precondition:] [The calling thread has no ownership of the mutex. ]]
[[Effects:] [If the tick period of `rel_time` is not exactly convertible to the native tick period, the duration shall be rounded up to the nearest native tick period.
Attempts to obtain upgrade lock ownership for the calling thread within the relative timeout specified by `rel_time`.
If the time specified by `rel_time` is less than or equal to `rel_time.zero()`, the function attempts to obtain ownership without blocking (as if by calling `__try_lock_upgrade()`).
The function returns within the timeout specified by `rel_time` only if it has obtained upgrade ownership of the mutex object.]]
[[Returns:] [`true` if upgrade ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has upgrade ownership of `m`.]]
[[Synchronization:] [If `__try_lock_upgrade_for(rel_time)` returns true, prior `__unlock_upgrade()` operations on the same object synchronize with this operation.]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:try_lock_upgrade_until `m.try_lock_upgrade_until(abs_time)`]
[variablelist
[[Precondition:] [The calling thread has no ownership of the mutex. ]]
[[Effects:] [The function attempts to obtain upgrade ownership of the mutex.
If `abs_time` has already passed, the function attempts to obtain upgrade ownership without blocking (as if by calling `__try_lock_upgrade()`).
The function returns before the absolute timeout specified by `abs_time` only if it has obtained upgrade ownership of the mutex object.]]
[[Returns:] [`true` if upgrade ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has upgrade ownership of `m`.]]
[[Synchronization:] [If `__try_lock_upgrade_until(abs_time)` returns true, prior `__unlock_upgrade()` operations on the same object synchronize with this operation.]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:try_unlock_shared_and_lock `m.try_unlock_shared_and_lock()`]
[variablelist
[[Precondition:] [The calling thread must hold a shared lock on the mutex.]]
[[Effects:] [The function attempts to atomically convert the ownership from shared to exclusive for the calling thread without blocking.
For this conversion to be successful, this thread must be the only thread holding any ownership of the lock.
If the conversion is not successful, the shared ownership of m is retained.]]
[[Returns:] [`true` if exclusive ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has exclusive ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_shared_and_lock()` returns true, prior `__unlock()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:try_unlock_shared_and_lock_for `m.try_unlock_shared_and_lock_for(rel_time)`]
[variablelist
[[Precondition:] [The calling thread shall hold a shared lock on the mutex.]]
[[Effects:] [If the tick period of `rel_time` is not exactly convertible to the native tick period, the duration shall be rounded up to the nearest native tick period.
The function attempts to atomically convert the ownership from shared to exclusive for the calling thread within the relative timeout specified by `rel_time`.
If the time specified by `rel_time` is less than or equal to `rel_time.zero()`, the function attempts to obtain exclusive ownership without blocking (as if by calling `try_unlock_shared_and_lock()`).
The function shall return within the timeout specified by `rel_time` only if it has obtained exclusive ownership of the mutex object.
For this conversion to be successful, this thread must be the only thread holding any ownership of the lock at the moment of conversion.
If the conversion is not successful, the shared ownership of the mutex is retained.]]
[[Returns:] [`true` if exclusive ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has exclusive ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_shared_and_lock_for(rel_time)` returns true, prior `__unlock()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:try_unlock_shared_and_lock_until `m.try_unlock_shared_and_lock_until(abs_time)`]
[variablelist
[[Precondition:] [The calling thread shall hold a shared lock on the mutex.]]
[[Effects:] [The function attempts to atomically convert the ownership from shared to exclusive for the calling thread within the absolute timeout specified by `abs_time`.
If `abs_time` has already passed, the function attempts to obtain exclusive ownership without blocking (as if by calling `try_unlock_shared_and_lock()`).
The function shall return before the absolute timeout specified by `abs_time` only if it has obtained exclusive ownership of the mutex object.
For this conversion to be successful, this thread must be the only thread holding any ownership of the lock at the moment of conversion.
If the conversion is not successful, the shared ownership of the mutex is retained.]]
[[Returns:] [`true` if exclusive ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has exclusive ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_shared_and_lock_until(rel_time)` returns true, prior `__unlock()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:unlock_and_lock_shared `m.unlock_and_lock_shared()`]
[variablelist
[[Precondition:] [The calling thread shall hold an exclusive lock on `m`.]]
[[Effects:] [Atomically converts the ownership from exclusive to shared for the calling thread.]]
[[Postcondition:] [The current thread has shared ownership of `m`.]]
[[Synchronization:] [This operation synchronizes with subsequent lock operations that obtain ownership of the same object.]]
[[Throws:] [Nothing]]
]
[endsect]
[section:try_unlock_shared_and_lock_upgrade `m.try_unlock_shared_and_lock_upgrade()`]
[variablelist
[[Precondition:] [The calling thread shall hold a shared lock on the mutex.]]
[[Effects:] [The function attempts to atomically convert the ownership from shared to upgrade for the calling thread without blocking.
For this conversion to be successful, there must be no thread holding upgrade ownership of this object.
If the conversion is not successful, the shared ownership of the mutex is retained.]]
[[Returns:] [`true` if upgrade ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has upgrade ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_shared_and_lock_upgrade()` returns true, prior `__unlock_upgrade()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:try_unlock_shared_and_lock_upgrade_for `m.try_unlock_shared_and_lock_upgrade_for(rel_time)`]
[variablelist
[[Precondition:] [The calling thread shall hold a shared lock on the mutex.]]
[[Effects:] [If the tick period of `rel_time` is not exactly convertible to the native tick period, the duration shall be rounded up to the nearest native tick period.
The function attempts to atomically convert the ownership from shared to upgrade for the calling thread within the relative timeout specified by `rel_time`.
If the time specified by `rel_time` is less than or equal to `rel_time.zero()`, the function attempts to obtain upgrade ownership without blocking (as if by calling `__try_unlock_shared_and_lock_upgrade()`).
The function shall return within the timeout specified by `rel_time` only if it has obtained exclusive ownership of the mutex object.
For this conversion to be successful, there must be no thread holding upgrade ownership of this object at the moment of conversion.
If the conversion is not successful, the shared ownership of m is retained.]]
[[Returns:] [`true` if upgrade ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has upgrade ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_shared_and_lock_upgrade_for(rel_time)` returns true, prior `__unlock_upgrade()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:try_unlock_shared_and_lock_upgrade_until `m.try_unlock_shared_and_lock_upgrade_until(abs_time)`]
[variablelist
[[Precondition:] [The calling thread shall hold a shared lock on the mutex.]]
[[Effects:] [The function attempts to atomically convert the ownership from shared to upgrade for the calling thread within the absolute timeout specified by `abs_time`.
If `abs_time` has already passed, the function attempts to obtain upgrade ownership without blocking (as if by calling `__try_unlock_shared_and_lock_upgrade()`).
The function shall return before the absolute timeout specified by `abs_time` only if it has obtained upgrade ownership of the mutex object.
For this conversion to be successful, there must be no thread holding upgrade ownership of this object at the moment of conversion.
If the conversion is not successful, the shared ownership of the mutex is retained.]]
[[Returns:] [`true` if upgrade ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has upgrade ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_shared_and_lock_upgrade_until(rel_time)` returns true, prior `__unlock_upgrade()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:unlock_and_lock_upgrade `m.unlock_and_lock_upgrade()`]
[variablelist
[[Precondition:] [The current thread has exclusive ownership of `m`.]]
[[Effects:] [Atomically releases exclusive ownership of `m` by the current thread and acquires upgrade ownership of `m`
without blocking.]]
[[Postcondition:] [The current thread has upgrade ownership of `m`.]]
[[Synchronization:] [This operation synchronizes with subsequent lock operations that obtain ownership of the same object.]]
[[Throws:] [Nothing]]
]
[endsect]
[section:unlock_upgrade_and_lock `m.unlock_upgrade_and_lock()`]
[variablelist
[[Precondition:] [The current thread has upgrade ownership of `m`.]]
[[Effects:] [Atomically releases upgrade ownership of `m` by the current thread and acquires exclusive ownership of `m`. If
any other threads have shared ownership, blocks until exclusive ownership can be acquired.]]
[[Postcondition:] [The current thread has exclusive ownership of `m`.]]
[[Synchronization:] [This operation synchronizes with prior `__unlock_shared()` and subsequent lock operations that obtain ownership of the same object.]]
[[Throws:] [Nothing]]
]
[endsect]
[section:try_unlock_upgrade_and_lock `m.try_unlock_upgrade_and_lock()`]
[variablelist
[[Precondition:] [The calling thread shall hold a upgrade lock on the mutex.]]
[[Effects:] [The function attempts to atomically convert the ownership from upgrade to exclusive for the calling thread without blocking.
For this conversion to be successful, this thread must be the only thread holding any ownership of the lock.
If the conversion is not successful, the upgrade ownership of m is retained.]]
[[Returns:] [`true` if exclusive ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has exclusive ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_upgrade_and_lock()` returns true, prior `__unlock()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:try_unlock_upgrade_and_lock_for `m.try_unlock_upgrade_and_lock_for(rel_time)`]
[variablelist
[[Precondition:] [The calling thread shall hold a upgrade lock on the mutex.]]
[[Effects:] [If the tick period of `rel_time` is not exactly convertible to the native tick period, the duration shall be rounded up to the nearest native tick period.
The function attempts to atomically convert the ownership from upgrade to exclusive for the calling thread within the relative timeout specified by `rel_time`.
If the time specified by `rel_time` is less than or equal to `rel_time.zero()`, the function attempts to obtain exclusive ownership without blocking (as if by calling `__try_unlock_upgrade_and_lock()`).
The function shall return within the timeout specified by `rel_time` only if it has obtained exclusive ownership of the mutex object.
For this conversion to be successful, this thread shall be the only thread holding any ownership of the lock at the moment of conversion.
If the conversion is not successful, the upgrade ownership of m is retained.]]
[[Returns:] [`true` if exclusive ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has exclusive ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_upgrade_and_lock_for(rel_time)` returns true, prior `__unlock()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:try_unlock_upgrade_and_lock_until `m.try_unlock_upgrade_and_lock_until(abs_time)`]
[variablelist
[[Precondition:] [The calling thread shall hold a upgrade lock on the mutex.]]
[[Effects:] [The function attempts to atomically convert the ownership from upgrade to exclusive for the calling thread within the absolute timeout specified by `abs_time`.
If `abs_time` has already passed, the function attempts to obtain exclusive ownership without blocking (as if by calling `__try_unlock_upgrade_and_lock()`).
The function shall return before the absolute timeout specified by `abs_time` only if it has obtained exclusive ownership of the mutex object.
For this conversion to be successful, this thread shall be the only thread holding any ownership of the lock at the moment of conversion.
If the conversion is not successful, the upgrade ownership of m is retained.]]
[[Returns:] [`true` if exclusive ownership was acquired for the current thread, `false` otherwise.]]
[[Postcondition:] [If the call returns `true`, the current thread has exclusive ownership of `m`.]]
[[Synchronization:] [If `__try_unlock_upgrade_and_lock_for(rel_time)` returns true, prior `__unlock()` and subsequent lock operations on the same object synchronize with this operation. ]]
[[Throws:] [Nothing]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:unlock_upgrade_and_lock_shared `m.unlock_upgrade_and_lock_shared()`]
[variablelist
[[Precondition:] [The current thread has upgrade ownership of `m`.]]
[[Effects:] [Atomically releases upgrade ownership of `m` by the current thread and acquires shared ownership of `m` without
blocking.]]
[[Postcondition:] [The current thread has shared ownership of `m`.]]
[[Synchronization:] [This operation synchronizes with prior `unlock_shared()` and subsequent lock operations that obtain ownership of the same object.]]
[[Throws:] [Nothing]]
]
[endsect]
[endsect]
[endsect]
[section:lock_option Lock Options]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/locks_options.hpp>
namespace boost
{
struct defer_lock_t {};
struct try_to_lock_t {};
struct adopt_lock_t {};
constexpr defer_lock_t defer_lock;
constexpr try_to_lock_t try_to_lock;
constexpr adopt_lock_t adopt_lock;
[section:lock_tags Lock option tags]
#include <boost/thread/locks.hpp>
#include <boost/thread/locks_options.hpp>
struct defer_lock_t {};
struct try_to_lock_t {};
struct adopt_lock_t {};
const defer_lock_t defer_lock;
const try_to_lock_t try_to_lock;
const adopt_lock_t adopt_lock;
These tags are used in scoped locks constructors to specify a specific behavior.
*`defer_lock_t`: is used to construct the scoped lock without locking it.
*`try_to_lock_t`: is used to construct the scoped lock trying to lock it.
*`adopt_lock_t`: is used to construct the scoped lock without locking it but adopting ownership.
[endsect]
[endsect]
[section:lock_guard Lock Guard]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/lock_guard.hpp>
namespace boost
{
template<typename Lockable>
class lock_guard
#if ! defined BOOST_THREAD_NO_MAKE_LOCK_GUARD
template <typename Lockable>
lock_guard<Lockable> make_lock_guard(Lockable& mtx); // EXTENSION
template <typename Lockable>
lock_guard<Lockable> make_lock_guard(Lockable& mtx, adopt_lock_t); // EXTENSION
#endif
}
[section:lock_guard Class template `lock_guard`]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/lock_guard.hpp>
template<typename Lockable>
class lock_guard
{
public:
explicit lock_guard(Lockable& m_);
lock_guard(Lockable& m_,boost::adopt_lock_t);
~lock_guard();
};
__lock_guard__ is very simple: on construction it
acquires ownership of the implementation of the __lockable_concept__ supplied as
the constructor parameter. On destruction, the ownership is released. This
provides simple RAII-style locking of a __lockable_concept_type__ object, to facilitate exception-safe
locking and unlocking. In addition, the [link
thread.synchronization.lock_guard.lock_guard.constructor_adopt `lock_guard(Lockable &
m,boost::adopt_lock_t)` constructor] allows the __lock_guard__ object to
take ownership of a lock already held by the current thread.
[section:constructor `lock_guard(Lockable & m)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [lock_ref_link `m.lock()`].]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[section:constructor_adopt `lock_guard(Lockable & m,boost::adopt_lock_t)`]
[variablelist
[[Precondition:] [The current thread owns a lock on `m` equivalent to one
obtained by a call to [lock_ref_link `m.lock()`].]]
[[Effects:] [Stores a reference to `m`. Takes ownership of the lock state of
`m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:destructor `~lock_guard()`]
[variablelist
[[Effects:] [Invokes [unlock_ref_link `m.unlock()`] on the __lockable_concept_type__
object passed to the constructor.]]
[[Throws:] [Nothing.]]
]
[endsect]
[endsect]
[section:make_lock_guard Non Member Function `make_lock_guard`]
template <typename Lockable>
lock_guard<Lockable> make_lock_guard(Lockable& m); // EXTENSION
[variablelist
[[Returns:] [a lock_guard as if initialized with `{m}`.]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[section:make_lock_guard_adopt Non Member Function `make_lock_guard`]
template <typename Lockable>
lock_guard<Lockable> make_lock_guard(Lockable& m, adopt_lock_t); // EXTENSION
[variablelist
[[Returns:] [a lock_guard as if initialized with `{m, adopt_lock}`.]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[endsect]
[section:lock_concepts Lock Concepts]
[section:StrictLock StrictLock -- EXTENSION]
// #include <boost/thread/lock_concepts.hpp>
namespace boost
{
template<typename Lock>
class StrictLock;
}
A StrictLock is a lock that ensures that the associated mutex is locked during the lifetime of the lock.
A type `L` meets the StrictLock requirements if the following expressions are well-formed and have the specified semantics
* `L::mutex_type`
* `is_strict_lock<L>`
* `cl.owns_lock(m);`
and BasicLockable<L::mutex_type>
where
* `cl` denotes a value of type `L const&`,
* `m` denotes a value of type `L::mutex_type const*`,
[section: mutex_type `L::mutex_type`]
The type L::mutex_type denotes the mutex that is locked by this lock.
[endsect] [/ mutex_type]
[section:is_strict_lock_sur_parole `is_strict_lock_sur_parole<L>`]
As the semantic "ensures that the associated mutex is locked during the lifetime of the lock. " can not be described by syntactic requirements a `is_strict_lock_sur_parole` trait must be specialized by the user defining the lock so that the following assertion is true:
is_strict_lock_sur_parole<L>::value == true
[endsect] [/ is_strict_lock_sur_parole]
[section:owns_lock `cl.owns_lock(m);`]
[variablelist
[[Return Type:] [`bool`]]
[[Returns:] [Whether the strict lock is locking the mutex `m`]]
[[Throws:] [Nothing.]]
]
[endsect] [/ owns_lock]
[section Models]
The following classes are models of `StrictLock`:
* strict_lock: ensured by construction,
* nested_strict_lock: "sur parole" as the user could use adopt_lock_t on unique_lock constructor overload without having locked the mutex,
* __lock_guard__: "sur parole" as the user could use adopt_lock_t constructor overload without having locked the mutex.
[endsect] [/ Models]
[endsect] [/ Strict Lock]
[endsect] [/ Lock Concepts]
[section:locks Lock Types]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/lock_types.hpp>
namespace boost
{
template<typename Lockable>
class unique_lock;
template<typename Mutex>
void swap(unique_lock <Mutex>& lhs, unique_lock <Mutex>& rhs);
template<typename Lockable>
class shared_lock; // C++14
template<typename Mutex>
void swap(shared_lock<Mutex>& lhs,shared_lock<Mutex>& rhs); // C++14
template<typename Lockable>
class upgrade_lock; // EXTENSION
template<typename Mutex>
void swap(upgrade_lock <Mutex>& lhs, upgrade_lock <Mutex>& rhs); // EXTENSION
template <class Mutex>
class upgrade_to_unique_lock; // EXTENSION
}
[section:unique_lock Class template `unique_lock`]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/lock_types.hpp>
template<typename Lockable>
class unique_lock
{
public:
typedef Lockable mutex_type;
unique_lock() noexcept;
explicit unique_lock(Lockable& m_);
unique_lock(Lockable& m_,adopt_lock_t);
unique_lock(Lockable& m_,defer_lock_t) noexcept;
unique_lock(Lockable& m_,try_to_lock_t);
#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION
unique_lock(shared_lock<mutex_type>&& sl, try_to_lock_t); // C++14
template <class Clock, class Duration>
unique_lock(shared_lock<mutex_type>&& sl,
const chrono::time_point<Clock, Duration>& abs_time); // C++14
template <class Rep, class Period>
unique_lock(shared_lock<mutex_type>&& sl,
const chrono::duration<Rep, Period>& rel_time); // C++14
#endif
template <class Clock, class Duration>
unique_lock(Mutex& mtx, const chrono::time_point<Clock, Duration>& t);
template <class Rep, class Period>
unique_lock(Mutex& mtx, const chrono::duration<Rep, Period>& d);
~unique_lock();
unique_lock(unique_lock const&) = delete;
unique_lock& operator=(unique_lock const&) = delete;
unique_lock(unique_lock<Lockable>&& other) noexcept;
explicit unique_lock(upgrade_lock<Lockable>&& other) noexcept; // EXTENSION
unique_lock& operator=(unique_lock<Lockable>&& other) noexcept;
void swap(unique_lock& other) noexcept;
Lockable* release() noexcept;
void lock();
bool try_lock();
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock();
explicit operator bool() const noexcept;
bool owns_lock() const noexcept;
mutex_type* mutex() const noexcept;
#if defined BOOST_THREAD_USE_DATE_TIME || defined BOOST_THREAD_DONT_USE_CHRONO
unique_lock(Lockable& m_,system_time const& target_time);
template<typename TimeDuration>
bool timed_lock(TimeDuration const& relative_time);
bool timed_lock(::boost::system_time const& absolute_time);
#endif
};
__unique_lock__ is more complex than __lock_guard__: not only does it provide for RAII-style locking, it also allows for deferring
acquiring the lock until the __lock_ref__ member function is called explicitly, or trying to acquire the lock in a non-blocking
fashion, or with a timeout. Consequently, __unlock_ref__ is only called in the destructor if the lock object has locked the
__lockable_concept_type__ object, or otherwise adopted a lock on the __lockable_concept_type__ object.
Specializations of __unique_lock__ model the __TimedLockable concept if the supplied `Lockable` type itself models
__TimedLockable concept (e.g. `boost::unique_lock<boost::timed_mutex>`), or the __Lockable concept if the supplied `Lockable` type itself models
__Lockable concept (e.g. `boost::unique_lock<boost::mutex>`), or the __BasicLockable concept if the supplied `Lockable` type itself models
__BasicLockable concept.
An instance of __unique_lock__ is said to ['own] the lock state of a __lockable_concept_type__ `m` if __mutex_func_ref__ returns a
pointer to `m` and __owns_lock_ref__ returns `true`. If an object that ['owns] the lock state of a __lockable_concept_type__ object
is destroyed, then the destructor will invoke [unlock_ref_link `mutex()->unlock()`].
The member functions of __unique_lock__ are not thread-safe. In particular, __unique_lock__ is intended to model the ownership of a
__lockable_concept_type__ object by a particular thread, and the member functions that release ownership of the lock state
(including the destructor) must be called by the same thread that acquired ownership of the lock state.
[section:defaultconstructor `unique_lock()`]
[variablelist
[[Effects:] [Creates a lock object with no associated mutex.]]
[[Postcondition:] [__owns_lock_ref__ returns `false`. __mutex_func_ref__ returns `NULL`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:constructor `unique_lock(Lockable & m)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [lock_ref_link `m.lock()`].]]
[[Postcondition:] [__owns_lock_ref__ returns `true`. __mutex_func_ref__ returns `&m`.]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[section:constructor_adopt `unique_lock(Lockable & m,boost::adopt_lock_t)`]
[variablelist
[[Precondition:] [The current thread owns an exclusive lock on `m`.]]
[[Effects:] [Stores a reference to `m`. Takes ownership of the lock state of `m`.]]
[[Postcondition:] [__owns_lock_ref__ returns `true`. __mutex_func_ref__ returns `&m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:constructor_defer `unique_lock(Lockable & m,boost::defer_lock_t)`]
[variablelist
[[Effects:] [Stores a reference to `m`.]]
[[Postcondition:] [__owns_lock_ref__ returns `false`. __mutex_func_ref__ returns `&m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:constructor_try `unique_lock(Lockable & m,boost::try_to_lock_t)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [try_lock_ref_link
`m.try_lock()`], and takes ownership of the lock state if the call returns
`true`.]]
[[Postcondition:] [__mutex_func_ref__ returns `&m`. If the call to __try_lock_ref__
returned `true`, then __owns_lock_ref__ returns `true`, otherwise __owns_lock_ref__
returns `false`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:constructor_sh_try `unique_lock(shared_lock<mutex_type>&& sl, try_to_lock_t)`]
[variablelist
[[Requires:] [The supplied `Mutex` type must implement `__try_unlock_shared_and_lock()`.]]
[[Effects:] [Constructs an object of type __unique_lock. Let `pm` be the pointer to the mutex and `owns` the ownership state. Initializes `pm` with nullptr and `owns` with false.
If `sl.__owns_lock()` returns `false`, sets `pm` to the return value of `sl.release()`.
Else `sl.__owns_lock()` returns `true`, and in this case if `sl.mutex()->try_unlock_shared_and_lock()` returns `true`, sets `pm` to the value returned by `sl.release()` and sets `owns` to `true`.]]
[[Note:] [If `sl.owns_lock()` returns `true` and `sl.mutex()->try_unlock_shared_and_lock()` returns `false`, `sl` is not modified.]]
[[Throws:] [Nothing.]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:constructor_sh_until `unique_lock(shared_lock<mutex_type>&&, const chrono::time_point<Clock, Duration>&)`]
template <class Clock, class Duration>
unique_lock(shared_lock<mutex_type>&& sl,
const chrono::time_point<Clock, Duration>& abs_time);
[variablelist
[[Requires:] [The supplied `Mutex` type shall implement `__try_unlock_shared_and_lock_until(abs_time)`.]]
[[Effects:] [Constructs an object of type `__unique_lock`, initializing `pm` with `nullptr` and `owns` with `false`.
If `sl.__owns_lock_shared_ref__()` returns `false`, sets `pm` to the return value of `sl.release()`.
Else `sl.__owns_lock_shared_ref__()` returns `true`, and in this case if `sl.mutex()->__try_unlock_shared_and_lock_until(abs_time)` returns `true`, sets `pm` to the value returned by `sl.release()` and sets `owns` to `true`.]]
[[Note:] [If `sl.owns_lock()` returns `true` and `sl.mutex()-> __try_unlock_shared_and_lock_until(abs_time)` returns `false`, `sl` is not modified.]]
[[Throws:] [Nothing.]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:constructor_sh_for `unique_lock(shared_lock<mutex_type>&&, const chrono::duration<Rep, Period>&)`]
template <class Rep, class Period>
unique_lock(shared_lock<mutex_type>&& sl,
const chrono::duration<Rep, Period>& rel_time)
[variablelist
[[Requires:] [The supplied `Mutex` type shall implement `__try_unlock_shared_and_lock_for(rel_time)`.]]
[[Effects:] [Constructs an object of type `__unique_lock`, initializing `pm` with `nullptr` and `owns` with `false`.
If `sl.__owns_lock()` returns `false`, sets `pm` to the return value of `sl.release()`.
Else `sl.owns_lock()` returns `true`, and in this case if `sl.mutex()-> __try_unlock_shared_and_lock_for(rel_time)` returns `true`, sets `pm` to the value returned by `sl.release()` and sets `owns` to `true`.]]
[[Note:] [If `sl.owns_lock()` returns `true` and `sl.mutex()-> __try_unlock_shared_and_lock_for(rel_time)` returns `false`, `sl` is not modified.]]
[[Postcondition:] [.]]
[[Throws:] [Nothing.]]
[[Notes:] [Available only if `BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION` and `BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN` is defined on Windows platform]]
]
[endsect]
[section:constructor_abs_time `unique_lock(Lockable & m,boost::system_time const& abs_time)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [timed_lock_ref_link
`m.timed_lock(abs_time)`], and takes ownership of the lock state if the call
returns `true`.]]
[[Postcondition:] [__mutex_func_ref__ returns `&m`. If the call to __timed_lock_ref__
returned `true`, then __owns_lock_ref__ returns `true`, otherwise __owns_lock_ref__
returns `false`.]]
[[Throws:] [Any exceptions thrown by the call to [timed_lock_ref_link `m.timed_lock(abs_time)`].]]
]
[endsect]
[section:constructor_time_point `template <class Clock, class Duration> unique_lock(Lockable & m,const chrono::time_point<Clock, Duration>& abs_time)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes
`m.__try_lock_until(abs_time)`, and takes ownership of the lock state if the call
returns `true`.]]
[[Postcondition:] [__mutex_func_ref__ returns `&m`. If the call to __try_lock_until
returned `true`, then __owns_lock_ref__ returns `true`, otherwise __owns_lock_ref__
returns `false`.]]
[[Throws:] [Any exceptions thrown by the call to `m.__try_lock_until(abs_time)`.]]
]
[endsect]
[section:constructor_duration `template <class Rep, class Period> unique_lock(Lockable & m,const chrono::duration<Rep, Period>& abs_time)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes
`m.__try_lock_for(rel_time)`, and takes ownership of the lock state if the call
returns `true`.]]
[[Postcondition:] [__mutex_func_ref__ returns `&m`. If the call to __try_lock_for
returned `true`, then __owns_lock_ref__ returns `true`, otherwise __owns_lock_ref__
returns `false`.]]
[[Throws:] [Any exceptions thrown by the call to `m.__try_lock_for(rel_time)`.]]
]
[endsect]
[section:destructor `~unique_lock()`]
[variablelist
[[Effects:] [Invokes __mutex_func_ref__`->`[unlock_ref_link `unlock()`] if
__owns_lock_ref__ returns `true`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:owns_lock `bool owns_lock() const`]
[variablelist
[[Returns:] [`true` if the `*this` owns the lock on the __lockable_concept_type__
object associated with `*this`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:mutex `Lockable* mutex() const noexcept`]
[variablelist
[[Returns:] [A pointer to the __lockable_concept_type__ object associated with
`*this`, or `NULL` if there is no such object.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:explicit_bool_conversion `explicit operator bool() const`]
[variablelist
[[Returns:] [`__owns_lock_ref__()`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:release `Lockable* release()`]
[variablelist
[[Effects:] [The association between `*this` and the __lockable_concept_type__ object is removed, without affecting the lock state
of the __lockable_concept_type__ object. If __owns_lock_ref__ would have returned `true`, it is the responsibility of the calling
code to ensure that the __lockable_concept_type__ is correctly unlocked.]]
[[Returns:] [A pointer to the __lockable_concept_type__ object associated with `*this` at the point of the call, or `NULL` if there
is no such object.]]
[[Throws:] [Nothing.]]
[[Postcondition:] [`*this` is no longer associated with any __lockable_concept_type__ object. __mutex_func_ref__ returns `NULL` and
__owns_lock_ref__ returns `false`.]]
]
[endsect]
[endsect]
[section:shared_lock Class template `shared_lock` - C++14]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/lock_types.hpp>
template<typename Lockable>
class shared_lock
{
public:
typedef Lockable mutex_type;
// Shared locking
shared_lock();
explicit shared_lock(Lockable& m_);
shared_lock(Lockable& m_,adopt_lock_t);
shared_lock(Lockable& m_,defer_lock_t);
shared_lock(Lockable& m_,try_to_lock_t);
template <class Clock, class Duration>
shared_lock(Mutex& mtx, const chrono::time_point<Clock, Duration>& t);
template <class Rep, class Period>
shared_lock(Mutex& mtx, const chrono::duration<Rep, Period>& d);
~shared_lock();
shared_lock(shared_lock const&) = delete;
shared_lock& operator=(shared_lock const&) = delete;
shared_lock(shared_lock<Lockable> && other);
shared_lock& operator=(shared_lock<Lockable> && other);
void lock();
bool try_lock();
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock();
// Conversion from upgrade locking
explicit shared_lock(upgrade_lock<Lockable> && other); // EXTENSION
// Conversion from exclusive locking
explicit shared_lock(unique_lock<Lockable> && other);
// Setters
void swap(shared_lock& other);
mutex_type* release() noexcept;
// Getters
explicit operator bool() const;
bool owns_lock() const;
mutex_type mutex() const;
#if defined BOOST_THREAD_USE_DATE_TIME || defined BOOST_THREAD_DONT_USE_CHRONO
shared_lock(Lockable& m_,system_time const& target_time);
bool timed_lock(boost::system_time const& target_time);
#endif
};
Like __unique_lock__, __shared_lock__ models the __lockable_concept__, but rather than acquiring unique ownership of the supplied
__lockable_concept_type__ object, locking an instance of __shared_lock__ acquires shared ownership.
Like __unique_lock__, not only does it provide for RAII-style locking, it also allows for deferring acquiring the lock until the
__lock_ref__ member function is called explicitly, or trying to acquire the lock in a non-blocking fashion, or with a
timeout. Consequently, __unlock_ref__ is only called in the destructor if the lock object has locked the __lockable_concept_type__
object, or otherwise adopted a lock on the __lockable_concept_type__ object.
An instance of __shared_lock__ is said to ['own] the lock state of a __lockable_concept_type__ `m` if __mutex_func_ref__ returns a
pointer to `m` and __owns_lock_ref__ returns `true`. If an object that ['owns] the lock state of a __lockable_concept_type__ object
is destroyed, then the destructor will invoke [unlock_shared_ref_link `mutex()->unlock_shared()`].
The member functions of __shared_lock__ are not thread-safe. In particular, __shared_lock__ is intended to model the shared
ownership of a __lockable_concept_type__ object by a particular thread, and the member functions that release ownership of the lock
state (including the destructor) must be called by the same thread that acquired ownership of the lock state.
[section:defaultconstructor `shared_lock()`]
[variablelist
[[Effects:] [Creates a lock object with no associated mutex.]]
[[Postcondition:] [__owns_lock_ref__ returns `false`. __mutex_func_ref__ returns `NULL`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:constructor `shared_lock(Lockable & m)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [lock_shared_ref_link `m.lock_shared()`].]]
[[Postcondition:] [__owns_lock_shared_ref__ returns `true`. __mutex_func_ref__ returns `&m`.]]
[[Throws:] [Any exception thrown by the call to [lock_shared_ref_link `m.lock_shared()`].]]
]
[endsect]
[section:constructor_adopt `shared_lock(Lockable & m,boost::adopt_lock_t)`]
[variablelist
[[Precondition:] [The current thread owns an exclusive lock on `m`.]]
[[Effects:] [Stores a reference to `m`. Takes ownership of the lock state of `m`.]]
[[Postcondition:] [__owns_lock_shared_ref__ returns `true`. __mutex_func_ref__ returns `&m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:constructor_defer `shared_lock(Lockable & m,boost::defer_lock_t)`]
[variablelist
[[Effects:] [Stores a reference to `m`.]]
[[Postcondition:] [__owns_lock_shared_ref__ returns `false`. __mutex_func_ref__ returns `&m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:constructor_try `shared_lock(Lockable & m,boost::try_to_lock_t)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [try_lock_shared_ref_link
`m.try_lock_shared()`], and takes ownership of the lock state if the call returns
`true`.]]
[[Postcondition:] [__mutex_func_ref__ returns `&m`. If the call to __try_lock_shared_ref__
returned `true`, then __owns_lock_shared_ref__ returns `true`, otherwise __owns_lock_shared_ref__
returns `false`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:constructor_abs_time `shared_lock(Lockable & m,boost::system_time const& abs_time)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [timed_lock_shared_ref_link
`m.timed_lock(abs_time)`], and takes ownership of the lock state if the call
returns `true`.]]
[[Postcondition:] [__mutex_func_ref__ returns `&m`. If the call to __timed_lock_shared_ref__
returned `true`, then __owns_lock_shared_ref__ returns `true`, otherwise __owns_lock_shared_ref__
returns `false`.]]
[[Throws:] [Any exceptions thrown by the call to [timed_lock_shared_ref_link `m.timed_lock(abs_time)`].]]
]
[endsect]
[section:destructor `~shared_lock()`]
[variablelist
[[Effects:] [Invokes __mutex_func_ref__`->`[unlock_shared_ref_link `unlock_shared()`] if
__owns_lock_shared_ref__ returns `true`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:owns_lock `bool owns_lock() const`]
[variablelist
[[Returns:] [`true` if the `*this` owns the lock on the __lockable_concept_type__
object associated with `*this`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:mutex `Lockable* mutex() const`]
[variablelist
[[Returns:] [A pointer to the __lockable_concept_type__ object associated with
`*this`, or `NULL` if there is no such object.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:explicit_operator_bool `explicit operator bool() const`]
[variablelist
[[Returns:] [__owns_lock_shared_ref__.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:release `Lockable* release()`]
[variablelist
[[Effects:] [The association between `*this` and the __lockable_concept_type__ object is removed, without affecting the lock state
of the __lockable_concept_type__ object. If __owns_lock_shared_ref__ would have returned `true`, it is the responsibility of the calling
code to ensure that the __lockable_concept_type__ is correctly unlocked.]]
[[Returns:] [A pointer to the __lockable_concept_type__ object associated with `*this` at the point of the call, or `NULL` if there
is no such object.]]
[[Throws:] [Nothing.]]
[[Postcondition:] [`*this` is no longer associated with any __lockable_concept_type__ object. __mutex_func_ref__ returns `NULL` and
__owns_lock_shared_ref__ returns `false`.]]
]
[endsect]
[endsect]
[section:upgrade_lock Class template `upgrade_lock` - EXTENSION]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/lock_types.hpp>
template<typename Lockable>
class upgrade_lock
{
public:
typedef Lockable mutex_type;
// Upgrade locking
upgrade_lock();
explicit upgrade_lock(mutex_type& m_);
upgrade_lock(mutex_type& m, defer_lock_t) noexcept;
upgrade_lock(mutex_type& m, try_to_lock_t);
upgrade_lock(mutex_type& m, adopt_lock_t);
template <class Clock, class Duration>
upgrade_lock(mutex_type& m,
const chrono::time_point<Clock, Duration>& abs_time);
template <class Rep, class Period>
upgrade_lock(mutex_type& m,
const chrono::duration<Rep, Period>& rel_time);
~upgrade_lock();
upgrade_lock(const upgrade_lock& other) = delete;
upgrade_lock& operator=(const upgrade_lock<Lockable> & other) = delete;
upgrade_lock(upgrade_lock<Lockable> && other);
upgrade_lock& operator=(upgrade_lock<Lockable> && other);
void lock();
bool try_lock();
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock();
#ifdef BOOST_THREAD_PROVIDES_SHARED_MUTEX_UPWARDS_CONVERSION
// Conversion from shared locking
upgrade_lock(shared_lock<mutex_type>&& sl, try_to_lock_t);
template <class Clock, class Duration>
upgrade_lock(shared_lock<mutex_type>&& sl,
const chrono::time_point<Clock, Duration>& abs_time);
template <class Rep, class Period>
upgrade_lock(shared_lock<mutex_type>&& sl,
const chrono::duration<Rep, Period>& rel_time);
#endif
// Conversion from exclusive locking
explicit upgrade_lock(unique_lock<Lockable> && other);
// Setters
void swap(upgrade_lock& other);
mutex_type* release() noexcept;
// Getters
explicit operator bool() const;
bool owns_lock() const;
mutex_type mutex() const;
};
Like __unique_lock__, __upgrade_lock__ models the __lockable_concept__, but rather than acquiring unique ownership of the supplied
__lockable_concept_type__ object, locking an instance of __upgrade_lock__ acquires upgrade ownership.
Like __unique_lock__, not only does it provide for RAII-style locking, it also allows for deferring acquiring the lock until the
__lock_ref__ member function is called explicitly, or trying to acquire the lock in a non-blocking fashion, or with a
timeout. Consequently, __unlock_ref__ is only called in the destructor if the lock object has locked the __lockable_concept_type__
object, or otherwise adopted a lock on the __lockable_concept_type__ object.
An instance of __upgrade_lock__ is said to ['own] the lock state of a __lockable_concept_type__ `m` if __mutex_func_ref__ returns a
pointer to `m` and __owns_lock_ref__ returns `true`. If an object that ['owns] the lock state of a __lockable_concept_type__ object
is destroyed, then the destructor will invoke [unlock_upgrade_ref_link `mutex()->unlock_upgrade()`].
The member functions of __upgrade_lock__ are not thread-safe. In particular, __upgrade_lock__ is intended to model the upgrade
ownership of a __upgrade_lockable_concept_type__ object by a particular thread, and the member functions that release ownership of the lock
state (including the destructor) must be called by the same thread that acquired ownership of the lock state.
[endsect]
[section:upgrade_to_unique_lock Class template `upgrade_to_unique_lock` -- EXTENSION]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/lock_types.hpp>
template <class Lockable>
class upgrade_to_unique_lock
{
public:
typedef Lockable mutex_type;
explicit upgrade_to_unique_lock(upgrade_lock<Lockable>& m_);
~upgrade_to_unique_lock();
upgrade_to_unique_lock(upgrade_to_unique_lock const& other) = delete;
upgrade_to_unique_lock& operator=(upgrade_to_unique_lock<Lockable> const& other) = delete;
upgrade_to_unique_lock(upgrade_to_unique_lock<Lockable> && other);
upgrade_to_unique_lock& operator=(upgrade_to_unique_lock<Lockable> && other);
void swap(upgrade_to_unique_lock& other);
explicit operator bool() const;
bool owns_lock() const;
mutex_type* mutex() const;
};
__upgrade_to_unique_lock__ allows for a temporary upgrade of an __upgrade_lock__ to exclusive ownership. When constructed with a
reference to an instance of __upgrade_lock__, if that instance has upgrade ownership on some __lockable_concept_type__ object, that
ownership is upgraded to exclusive ownership. When the __upgrade_to_unique_lock__ instance is destroyed, the ownership of the
__lockable_concept_type__ is downgraded back to ['upgrade ownership].
[endsect]
[section:scoped_try_lock Mutex-specific class `scoped_try_lock` -- DEPRECATED]
class MutexType::scoped_try_lock
{
private:
MutexType::scoped_try_lock(MutexType::scoped_try_lock<MutexType>& other);
MutexType::scoped_try_lock& operator=(MutexType::scoped_try_lock<MutexType>& other);
public:
MutexType::scoped_try_lock();
explicit MutexType::scoped_try_lock(MutexType& m);
MutexType::scoped_try_lock(MutexType& m_,adopt_lock_t);
MutexType::scoped_try_lock(MutexType& m_,defer_lock_t);
MutexType::scoped_try_lock(MutexType& m_,try_to_lock_t);
MutexType::scoped_try_lock(MutexType::scoped_try_lock<MutexType>&& other);
MutexType::scoped_try_lock& operator=(MutexType::scoped_try_lock<MutexType>&& other);
void swap(MutexType::scoped_try_lock&& other);
void lock();
bool try_lock();
void unlock();
MutexType* mutex() const;
MutexType* release();
explicit operator bool() const;
bool owns_lock() const;
};
The member typedef `scoped_try_lock` is provided for each distinct
`MutexType` as a typedef to a class with the preceding definition. The
semantics of each constructor and member function are identical to
those of [unique_lock_link `boost::unique_lock<MutexType>`] for the same `MutexType`, except
that the constructor that takes a single reference to a mutex will
call [try_lock_ref_link `m.try_lock()`] rather than `m.lock()`.
[endsect]
[endsect]
[/
[section:other_mutex Other Mutex Types]
[section: reverse_mutex Class template `reverse_mutex`]
//#include <boost/thread/reverse_mutex.hpp>
namespace boost
{
template<typename BasicLockable>
class reverse_mutex
{
public:
typedef BasicLockable mutex_type;
reverse_mutex(reverse_mutex const&) = delete;
reverse_mutex& operator=(reverse_mutex const&) = delete;
explicit reverse_mutex(mutex_type& m_);
~reverse_mutex();
void lock();
void unlock();
};
}
__reverse_mutex reverse the operations of a __BasicLockable, that unlocks the lockable when `lock()` is called and locks it when `unlock()` is called.
[endsect]
[endsect]
]
[section:other_locks Other Lock Types - EXTENSION]
[section:strict_locks Strict Locks]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/strict_lock.hpp>
namespace boost
{
template<typename Lockable>
class strict_lock;
template <typename Lock>
class nested_strict_lock;
template <typename Lockable>
struct is_strict_lock_sur_parole<strict_lock<Lockable> >;
template <typename Lock>
struct is_strict_lock_sur_parole<nested_strict_lock<Lock> >;
#if ! defined BOOST_THREAD_NO_MAKE_STRICT_LOCK
template <typename Lockable>
strict_lock<Lockable> make_strict_lock(Lockable& mtx);
#endif
#if ! defined BOOST_THREAD_NO_MAKE_NESTED_STRICT_LOCK
template <typename Lock>
nested_strict_lock<Lock> make_nested_strict_lock(Lock& lk);
#endif
}
[section:strict_lock Class template `strict_lock`]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/strict_lock.hpp>
template<typename BasicLockable>
class strict_lock
{
public:
typedef BasicLockable mutex_type;
strict_lock(strict_lock const& m_) = delete;
strict_lock& operator=(strict_lock const& m_) = delete;
explicit strict_lock(mutex_type& m_);
~strict_lock();
bool owns_lock(mutex_type const* l) const noexcept;
};
__strict_lock is a model of __StrictLock.
__strict_lock is the simplest __StrictLock: on construction it acquires ownership of the implementation of the __BasicLockable concept supplied as the constructor parameter. On destruction, the ownership is released. This provides simple RAII-style locking of a __BasicLockable object, to facilitate exception-safe locking and unlocking.
[heading See also __lock_guard__]
[section:constructor `strict_lock(Lockable & m)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes [lock_ref_link `m.lock()`].]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[section:destructor `~strict_lock()`]
[variablelist
[[Effects:] [Invokes [unlock_ref_link `m.unlock()`] on the __lockable_concept_type__
object passed to the constructor.]]
[[Throws:] [Nothing.]]
]
[endsect]
[endsect]
[section:nested_strict_lock Class template `nested_strict_lock`]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/strict_lock.hpp>
template<typename Lock>
class nested_strict_lock
{
public:
typedef BasicLockable mutex_type;
nested_strict_lock(nested_strict_lock const& m_) = delete;
nested_strict_lock& operator=(nested_strict_lock const& m_) = delete;
explicit nested_strict_lock(Lock& lk),
~nested_strict_lock() noexcept;
bool owns_lock(mutex_type const* l) const noexcept;
};
__nested_strict_lock is a model of __StrictLock.
A nested strict lock is a scoped lock guard ensuring a mutex is locked on its
scope, by taking ownership of an nesting lock, locking the mutex on construction if not already locked
and restoring the ownership to the nesting lock on destruction.
[heading See also __strict_lock, __unique_lock]
[section:constructor `nested_strict_lock(Lock & lk)`]
[variablelist
[[Requires:] [`lk.mutex() != null_ptr`.]]
[[Effects:] [Stores the reference to the lock parameter `lk` and takes ownership on it.
If the lock doesn't owns the mutex lock it.
]]
[[Postcondition:] [`owns_lock(lk.mutex())`.]]
[[Throws:] [
- lock_error when BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is defined and lk.mutex() == null_ptr
- Any exception that @c lk.lock() can throw.
]]
]
[endsect]
[section:destructor `~nested_strict_lock() noexcept`]
[variablelist
[[Effects:] [Restores ownership to the nesting lock.]]
]
[endsect]
[section:owns_lock `bool owns_lock(mutex_type const* l) const noexcept`]
[variablelist
[[Return:] [Whether if this lock is locking that mutex.]]
]
[endsect]
[endsect]
[section:make_strict_lock Non Member Function `make_strict_lock`]
template <typename Lockable>
strict_lock<Lockable> make_strict_lock(Lockable& m); // EXTENSION
[variablelist
[[Returns:] [a strict_lock as if initialized with `{m}`.]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[section:make_nested_strict_lock Non Member Function `make_nested_strict_lock`]
template <typename Lock>
nested_strict_lock<Lock> make_nested_strict_lock(Lock& lk); // EXTENSION
[variablelist
[[Returns:] [a nested_strict_lock as if initialized with `{lk}`.]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `lk.lock()`].]]
]
[endsect]
[endsect]
[section:lock_ptrs Locking pointers]
// #include <boost/thread/synchroniezd_value.hpp>
// #include <boost/thread/strict_lock_ptr.hpp>
namespace boost
{
template<typename T, typename Lockable = mutex>
class strict_lock_ptr;
template<typename T, typename Lockable = mutex>
class const_strict_lock_ptr;
}
[/
template<typename T, typename Lockable = mutex>
class unique_lock_ptr;
template<typename T, typename Lockable = mutex>
class const_unique_lock_ptr;
]
[section:const_strict_lock_ptr Class template `const_strict_lock_ptr `]
// #include <boost/thread/synchroniezd_value.hpp>
// #include <boost/thread/strict_lock_ptr.hpp>
template <typename T, typename Lockable = mutex>
class const_strict_lock_ptr
{
public:
typedef T value_type;
typedef Lockable mutex_type;
const_strict_lock_ptr(const_strict_lock_ptr const& m_) = delete;
const_strict_lock_ptr& operator=(const_strict_lock_ptr const& m_) = delete;
const_strict_lock_ptr(T const& val, Lockable & mtx);
const_strict_lock_ptr(T const& val, Lockable & mtx, adopt_lock_t tag);
~const_strict_lock_ptr();
const T* operator->() const;
const T& operator*() const;
};
[section:constructor `const_strict_lock_ptr(T const&,Lockable&)`]
const_strict_lock_ptr(T const& val, Lockable & m);
[variablelist
[[Effects:] [Invokes [lock_ref_link `m.lock()`], stores a reference to it and to the value type `val`.]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[section:constructor_adopt `const_strict_lock_ptr(T const&,Lockable&,adopt_lock_t)`]
const_strict_lock_ptr(T const& val, Lockable & m, adopt_lock_t tag);
[variablelist
[[Effects:] [Stores a reference to it and to the value type `val`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:destructor `~const_strict_lock_ptr()`]
~const_strict_lock_ptr();
[variablelist
[[Effects:] [Invokes [unlock_ref_link `m.unlock()`] on the __lockable_concept_type__
object passed to the constructor.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:indir `operator->() const`]
const T* operator->() const;
[variablelist
[[Return:] [return a constant pointer to the protected value.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:deref `operator*() const`]
const T& operator*() const;
[variablelist
[[Return:] [return a constant reference to the protected value.]]
[[Throws:] [Nothing.]]
]
[endsect]
[endsect] [/ const_strict_lock_ptr ]
[section:strict_lock_ptr Class template `strict_lock_ptr`]
// #include <boost/thread/synchroniezd_value.hpp>
// #include <boost/thread/strict_lock_ptr.hpp>
template <typename T, typename Lockable = mutex>
class strict_lock_ptr : public const_strict_lock_ptr<T,Lockable>
{
public:
strict_lock_ptr(strict_lock_ptr const& m_) = delete;
strict_lock_ptr& operator=(strict_lock_ptr const& m_) = delete;
strict_lock_ptr(T & val, Lockable & mtx);
strict_lock_ptr(T & val, Lockable & mtx, adopt_lock_t tag);
~strict_lock_ptr();
T* operator->();
T& operator*();
};
[section:constructor `strict_lock_ptr(T const&,Lockable&)`]
strict_lock_ptr(T const& val, Lockable & m);
[variablelist
[[Effects:] [Invokes [lock_ref_link `m.lock()`], stores a reference to it and to the value type `val`.]]
[[Throws:] [Any exception thrown by the call to [lock_ref_link `m.lock()`].]]
]
[endsect]
[section:constructor_adopt `strict_lock_ptr(T const&,Lockable&,adopt_lock_t)`]
strict_lock_ptr(T const& val, Lockable & m, adopt_lock_t tag);
[variablelist
[[Effects:] [Stores a reference to it and to the value type `val`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:destructor `~strict_lock_ptr()`]
~ strict_lock_ptr();
[variablelist
[[Effects:] [Invokes [unlock_ref_link `m.unlock()`] on the __lockable_concept_type__
object passed to the constructor.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:indir `operator->()`]
T* operator->();
[variablelist
[[Return:] [return a pointer to the protected value.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:deref `operator*()`]
T& operator*();
[variablelist
[[Return:] [return a reference to the protected value.]]
[[Throws:] [Nothing.]]
]
[endsect]
[endsect] [/ strict_lock_ptr ]
[endsect] [/ lock_ptrs ]
[section Externally Locked]
// #include <boost/thread/externally_locked.hpp>
template <class T, typename MutexType = boost::mutex>
class externally_locked;
template <class T, typename MutexType>
class externally_locked<T&, MutexType>;
template <typename T, typename MutexType>
void swap(externally_locked<T, MutexType> & lhs, externally_locked<T, MutexType> & rhs);
[section:externally_locked Template Class `externally_locked`]
// #include <boost/thread/externally_locked.hpp>
template <class T, typename MutexType>
class externally_locked
{
//BOOST_CONCEPT_ASSERT(( CopyConstructible<T> ));
BOOST_CONCEPT_ASSERT(( BasicLockable<MutexType> ));
public:
typedef MutexType mutex_type;
externally_locked(mutex_type& mtx, const T& obj);
externally_locked(mutex_type& mtx,T&& obj);
explicit externally_locked(mutex_type& mtx);
externally_locked(externally_locked const& rhs);
externally_locked(externally_locked&& rhs);
externally_locked& operator=(externally_locked const& rhs);
externally_locked& operator=(externally_locked&& rhs);
// observers
T& get(strict_lock<mutex_type>& lk);
const T& get(strict_lock<mutex_type>& lk) const;
template <class Lock>
T& get(nested_strict_lock<Lock>& lk);
template <class Lock>
const T& get(nested_strict_lock<Lock>& lk) const;
template <class Lock>
T& get(Lock& lk);
template <class Lock>
T const& get(Lock& lk) const;
mutex_type* mutex() const noexcept;
// modifiers
void lock();
void unlock();
bool try_lock();
void swap(externally_locked&);
};
`externally_locked` is a model of __Lockable, it cloaks an object of type `T`, and actually provides full
access to that object through the get and set member functions, provided you
pass a reference to a strict lock object.
Only the specificities respect to __Lockable are described here.
[///////////////////////////////]
[section:constructor1 `externally_locked(mutex_type&, const T&)`]
externally_locked(mutex_type& mtx, const T& obj);
[variablelist
[[Requires:] [T is a model of CopyConstructible.]]
[[Effects:] [Constructs an externally locked object copying the cloaked type.]]
[[Throws:] [Any exception thrown by the call to `T(obj)`.]]
]
[endsect]
[///////////////////////////////]
[section:constructor2 `externally_locked(mutex_type&, T&&)`]
externally_locked(mutex_type& mtx,T&& obj);
[variablelist
[[Requires:] [T is a model of Movable.]]
[[Effects:] [Constructs an externally locked object by moving the cloaked type.]]
[[Throws:] [Any exception thrown by the call to `T(obj)`.]]
]
[endsect]
[///////////////////////////////]
[section:constructor3 `externally_locked(mutex_type&)`]
externally_locked(mutex_type& mtx);
[variablelist
[[Requires:] [T is a model of DefaultConstructible.]]
[[Effects:] [Constructs an externally locked object by default constructing the cloaked type.]]
[[Throws:] [Any exception thrown by the call to `T()`.]]
]
[endsect]
[///////////////////////////////]
[section:constructor4 `externally_locked(externally_locked&&)`]
externally_locked(externally_locked&& rhs);
[variablelist
[[Requires:] [T is a model of Movable.]]
[[Effects:] [Move constructs an externally locked object by moving the cloaked type and copying the mutex reference ]]
[[Throws:] [Any exception thrown by the call to `T(T&&)`.]]
]
[endsect]
[///////////////////////////////]
[section:constructor5 `externally_locked(externally_locked&)`]
externally_locked(externally_locked& rhs);
[variablelist
[[Requires:] [T is a model of Copyable.]]
[[Effects:] [Copy constructs an externally locked object by copying the cloaked type and copying the mutex reference ]]
[[Throws:] [Any exception thrown by the call to `T(T&)`.]]
]
[endsect]
[///////////////////////////////]
[section:assign4 `externally_locked(externally_locked&&)`]
externally_locked& operator=(externally_locked&& rhs);
[variablelist
[[Requires:] [T is a model of Movable.]]
[[Effects:] [Move assigns an externally locked object by moving the cloaked type and copying the mutex reference ]]
[[Throws:] [Any exception thrown by the call to `T::operator=(T&&)`.]]
]
[endsect]
[///////////////////////////////]
[section:assign5 `externally_locked(externally_locked&)`]
externally_locked& operator=(externally_locked const& rhs);
[variablelist
[[Requires:] [T is a model of Copyable.]]
[[Effects:] [Copy assigns an externally locked object by copying the cloaked type and copying the mutex reference ]]
[[Throws:] [Any exception thrown by the call to `T::operator=(T&)`.]]
]
[endsect]
[///////////////////////////////]
[section:get1 `get(strict_lock<mutex_type>&)`]
T& get(strict_lock<mutex_type>& lk);
const T& get(strict_lock<mutex_type>& lk) const;
[variablelist
[[Requires:] [The `lk` parameter must be locking the associated mutex.]]
[[Returns:] [A reference to the cloaked object ]]
[[Throws:] [__lock_error__ if `BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED` is defined and the run-time preconditions are not satisfied .]]
]
[endsect]
[///////////////////////////////]
[section:get2 `get(strict_lock<nested_strict_lock<Lock>>&)`]
template <class Lock>
T& get(nested_strict_lock<Lock>& lk);
template <class Lock>
const T& get(nested_strict_lock<Lock>& lk) const;
[variablelist
[[Requires:] [`is_same<mutex_type, typename Lock::mutex_type>` and the `lk` parameter must be locking the associated mutex.]]
[[Returns:] [A reference to the cloaked object ]]
[[Throws:] [__lock_error__ if `BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED` is defined and the run-time preconditions are not satisfied .]]
]
[endsect]
[///////////////////////////////]
[section:get3 `get(strict_lock<nested_strict_lock<Lock>>&)`]
template <class Lock>
T& get(Lock& lk);
template <class Lock>
T const& get(Lock& lk) const;
[variablelist
[[Requires:] [`Lock` is a model of __StrictLock, `is_same<mutex_type, typename Lock::mutex_type>` and the `lk` parameter must be locking the associated mutex.]]
[[Returns:] [A reference to the cloaked object ]]
[[Throws:] [__lock_error__ if `BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED` is defined and the run-time preconditions are not satisfied .]]
]
[endsect]
[endsect]
[section:externally_locked_ref Template Class `externally_locked<T&>`]
// #include <boost/thread/externally_locked.hpp>
template <class T, typename MutexType>
class externally_locked<T&, MutexType>
{
//BOOST_CONCEPT_ASSERT(( CopyConstructible<T> ));
BOOST_CONCEPT_ASSERT(( BasicLockable<MutexType> ));
public:
typedef MutexType mutex_type;
externally_locked(mutex_type& mtx, T& obj);
explicit externally_locked(mutex_type& mtx);
externally_locked(externally_locked const& rhs) noexcept;
externally_locked(externally_locked&& rhs) noexcept;
externally_locked& operator=(externally_locked const& rhs) noexcept;
externally_locked& operator=(externally_locked&& rhs) noexcept;
// observers
T& get(strict_lock<mutex_type>& lk);
const T& get(strict_lock<mutex_type>& lk) const;
template <class Lock>
T& get(nested_strict_lock<Lock>& lk);
template <class Lock>
const T& get(nested_strict_lock<Lock>& lk) const;
template <class Lock>
T& get(Lock& lk);
template <class Lock>
T const& get(Lock& lk) const;
mutex_type* mutex() const noexcept;
// modifiers
void lock();
void unlock();
bool try_lock();
void swap(externally_locked&) noexcept;
};
`externally_locked` is a model of __Lockable, it cloaks an object of type `T`, and actually provides full
access to that object through the get and set member functions, provided you
pass a reference to a strict lock object.
Only the specificities respect to __Lockable are described here.
[///////////////////////////////]
[section:constructor1 `externally_locked<T&>(mutex_type&, T&)`]
externally_locked<T&>(mutex_type& mtx, T& obj) noexcept;
[variablelist
[[Effects:] [Constructs an externally locked object copying the cloaked reference.]]
]
[endsect]
[///////////////////////////////]
[section:constructor4 `externally_locked<T&>(externally_locked&&)`]
externally_locked(externally_locked&& rhs) noexcept;
[variablelist
[[Effects:] [Moves an externally locked object by moving the cloaked type and copying the mutex reference ]]
]
[endsect]
[///////////////////////////////]
[section:assign4 `externally_locked(externally_locked&&)`]
externally_locked& operator=(externally_locked&& rhs);
[variablelist
[[Effects:] [Move assigns an externally locked object by copying the cloaked reference and copying the mutex reference ]]
]
[endsect]
[///////////////////////////////]
[section:assign5 `externally_locked(externally_locked&)`]
externally_locked& operator=(externally_locked const& rhs);
[variablelist
[[Requires:] [T is a model of Copyable.]]
[[Effects:] [Copy assigns an externally locked object by copying the cloaked reference and copying the mutex reference ]]
[[Throws:] [Any exception thrown by the call to `T::operator=(T&)`.]]
]
[endsect]
[///////////////////////////////]
[section:get1 `get(strict_lock<mutex_type>&)`]
T& get(strict_lock<mutex_type>& lk);
const T& get(strict_lock<mutex_type>& lk) const;
[variablelist
[[Requires:] [The `lk` parameter must be locking the associated mutex.]]
[[Returns:] [A reference to the cloaked object ]]
[[Throws:] [__lock_error__ if `BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED` is defined and the run-time preconditions are not satisfied .]]
]
[endsect]
[///////////////////////////////]
[section:get2 `get(strict_lock<nested_strict_lock<Lock>>&)`]
template <class Lock>
T& get(nested_strict_lock<Lock>& lk);
template <class Lock>
const T& get(nested_strict_lock<Lock>& lk) const;
[variablelist
[[Requires:] [`is_same<mutex_type, typename Lock::mutex_type>` and the `lk` parameter must be locking the associated mutex.]]
[[Returns:] [A reference to the cloaked object ]]
[[Throws:] [__lock_error__ if `BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED` is defined and the run-time preconditions are not satisfied .]]
]
[endsect]
[///////////////////////////////]
[section:get3 `get(strict_lock<nested_strict_lock<Lock>>&)`]
template <class Lock>
T& get(Lock& lk);
template <class Lock>
T const& get(Lock& lk) const;
[variablelist
[[Requires:] [`Lock` is a model of __StrictLock, `is_same<mutex_type, typename Lock::mutex_type>` and the `lk` parameter must be locking the associated mutex.]]
[[Returns:] [A reference to the cloaked object ]]
[[Throws:] [__lock_error__ if `BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED` is defined and the run-time preconditions are not satisfied .]]
]
[endsect]
[endsect]
[///////////////////////////////]
[section:swap `swap(externally_locked&, externally_locked&)`]
template <typename T, typename MutexType>
void swap(externally_locked<T, MutexType> & lhs, externally_locked<T, MutexType> & rhs)
[endsect]
[endsect]
[section:shared_lock_guard Class template `shared_lock_guard`]
// #include <boost/thread/shared_lock_guard.hpp>
namespace boost
{
template<typename SharedLockable>
class shared_lock_guard
{
public:
shared_lock_guard(shared_lock_guard const&) = delete;
shared_lock_guard& operator=(shared_lock_guard const&) = delete;
explicit shared_lock_guard(SharedLockable& m_);
shared_lock_guard(SharedLockable& m_,boost::adopt_lock_t);
~shared_lock_guard();
};
}
__shared_lock_guard is very simple: on construction it
acquires shared ownership of the implementation of the __shared_lockable_concept__ supplied as
the constructor parameter. On destruction, the ownership is released. This
provides simple RAII-style locking of a __shared_lockable_concept_type__ object, to facilitate exception-safe
shared locking and unlocking.
In addition, the `__shared_lock_guard_constructor_adopt(SharedLockable &m, boost::adopt_lock_t)` constructor allows the __shared_lock_guard object to
take shared ownership of a lock already held by the current thread.
[section:constructor `shared_lock_guard(SharedLockable & m)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes `m.__lock_shared()`.]]
[[Throws:] [Any exception thrown by the call to `m.__lock_shared()`.]]
]
[endsect]
[section:constructor_adopt `shared_lock_guard(SharedLockable & m,boost::adopt_lock_t)`]
[variablelist
[[Precondition:] [The current thread owns a lock on `m` equivalent to one
obtained by a call to `m.__lock_shared()`.]]
[[Effects:] [Stores a reference to `m`. Takes ownership of the lock state of
`m`.]]
[[Throws:] [Nothing.]]
]
[endsect]
[section:destructor `~shared_lock_guard()`]
[variablelist
[[Effects:] [Invokes `m.__unlock_shared()` on the __shared_lockable_concept_type__ object passed to the constructor.]]
[[Throws:] [Nothing.]]
]
[endsect]
[endsect]
[section:reverse_lock Class template `reverse_lock`]
// #include <boost/thread/reverse_lock.hpp>
namespace boost
{
template<typename Lock>
class reverse_lock
{
public:
reverse_lock(reverse_lock const&) = delete;
reverse_lock& operator=(reverse_lock const&) = delete;
explicit reverse_lock(Lock& m_);
~reverse_lock();
};
}
__reverse_lock reverse the operations of a lock: it provide for RAII-style, that unlocks the lock at construction time and lock it at destruction time. In addition, it transfer ownership temporarily, so that the mutex can not be locked using the Lock.
An instance of __reverse_lock doesn't ['own] the lock never.
[section:constructor `reverse_lock(Lock & m)`]
[variablelist
[[Effects:] [Stores a reference to `m`. Invokes `m.__unlock()` if `m` owns his lock and then stores the mutex by calling `m.release()`.]]
[[Postcondition:] [`!m.__owns_lock() && m.mutex()==0`.]]
[[Throws:] [Any exception thrown by the call to `m.__unlock()`.]]
]
[endsect]
[section:destructor `~reverse_lock()`]
[variablelist
[[Effects:] [Let be mtx the stored mutex*. If not 0 Invokes `mtx->__lock()` and gives again the `mtx` to the `Lock` using the `adopt_lock_t` overload.]]
[[Throws:] [Any exception thrown by `mtx->__lock()`.]]
[[Remarks:] [Note that if `mtx->__lock()` throws an exception while unwinding the program will terminate, so don't use reverse_lock if an exception can be thrown.]]
]
[endsect]
[endsect] [/ reverse_lock<>]
[endsect]
[section:lock_functions Lock functions]
[section:lock_multiple Non-member function `lock(Lockable1,Lockable2,...)`]
// #include <boost/thread/locks.hpp>
// #include <boost/thread/lock_algorithms.hpp>
namespace boost
{
template<typename Lockable1,typename Lockable2>
void lock(Lockable1& l1,Lockable2& l2);
template<typename Lockable1,typename Lockable2,typename Lockable3>
void lock(Lockable1& l1,Lockable2& l2,Lockable3& l3);
template<typename Lockable1,typename Lockable2,typename Lockable3,typename Lockable4>
void lock(Lockable1& l1,Lockable2& l2,Lockable3& l3,Lockable4& l4);
template<typename Lockable1,typename Lockable2,typename Lockable3,typename Lockable4,typename Lockable5>
void lock(Lockable1& l1,Lockable2& l2,Lockable3& l3,Lockable4& l4,Lockable5& l5);
}
[variablelist
[[Effects:] [Locks the __lockable_concept_type__ objects supplied as
arguments in an unspecified and indeterminate order in a way that
avoids deadlock. It is safe to call this function concurrently from
multiple threads with the same mutexes (or other lockable objects) in
different orders without risk of deadlock. If any of the __lock_ref__
or __try_lock_ref__ operations on the supplied
__lockable_concept_type__ objects throws an exception any locks
acquired by the function will be released before the function exits.]]
[[Throws:] [Any exceptions thrown by calling __lock_ref__ or
__try_lock_ref__ on the supplied __lockable_concept_type__ objects.]]
[[Postcondition:] [All the supplied __lockable_concept_type__ objects
are locked by the calling thread.]]
]
[endsect]
[section:lock_range Non-member function `lock(begin,end)` // EXTENSION]
template<typename ForwardIterator>
void lock(ForwardIterator begin,ForwardIterator end);
[variablelist
[[Preconditions:] [The `value_type` of `ForwardIterator` must implement the __lockable_concept__]]
[[Effects:] [Locks all the __lockable_concept_type__ objects in the
supplied range in an unspecified and indeterminate order in a way that
avoids deadlock. It is safe to call this function concurrently from
multiple threads with the same mutexes (or other lockable objects) in
different orders without risk of deadlock. If any of the __lock_ref__
or __try_lock_ref__ operations on the __lockable_concept_type__
objects in the supplied range throws an exception any locks acquired
by the function will be released before the function exits.]]
[[Throws:] [Any exceptions thrown by calling __lock_ref__ or
__try_lock_ref__ on the supplied __lockable_concept_type__ objects.]]
[[Postcondition:] [All the __lockable_concept_type__ objects in the
supplied range are locked by the calling thread.]]
]
[endsect]
[section:try_lock_multiple Non-member function `try_lock(Lockable1,Lockable2,...)`]
template<typename Lockable1,typename Lockable2>
int try_lock(Lockable1& l1,Lockable2& l2);
template<typename Lockable1,typename Lockable2,typename Lockable3>
int try_lock(Lockable1& l1,Lockable2& l2,Lockable3& l3);
template<typename Lockable1,typename Lockable2,typename Lockable3,typename Lockable4>
int try_lock(Lockable1& l1,Lockable2& l2,Lockable3& l3,Lockable4& l4);
template<typename Lockable1,typename Lockable2,typename Lockable3,typename Lockable4,typename Lockable5>
int try_lock(Lockable1& l1,Lockable2& l2,Lockable3& l3,Lockable4& l4,Lockable5& l5);
[variablelist
[[Effects:] [Calls __try_lock_ref__ on each of the
__lockable_concept_type__ objects supplied as arguments. If any of the
calls to __try_lock_ref__ returns `false` then all locks acquired are
released and the zero-based index of the failed lock is returned.
If any of the __try_lock_ref__ operations on the supplied
__lockable_concept_type__ objects throws an exception any locks
acquired by the function will be released before the function exits.]]
[[Returns:] [`-1` if all the supplied __lockable_concept_type__ objects
are now locked by the calling thread, the zero-based index of the
object which could not be locked otherwise.]]
[[Throws:] [Any exceptions thrown by calling __try_lock_ref__ on the
supplied __lockable_concept_type__ objects.]]
[[Postcondition:] [If the function returns `-1`, all the supplied
__lockable_concept_type__ objects are locked by the calling
thread. Otherwise any locks acquired by this function will have been
released.]]
]
[endsect]
[section:try_lock_range Non-member function `try_lock(begin,end)` // EXTENSION]
template<typename ForwardIterator>
ForwardIterator try_lock(ForwardIterator begin,ForwardIterator end);
[variablelist
[[Preconditions:] [The `value_type` of `ForwardIterator` must implement the __lockable_concept__]]
[[Effects:] [Calls __try_lock_ref__ on each of the
__lockable_concept_type__ objects in the supplied range. If any of the
calls to __try_lock_ref__ returns `false` then all locks acquired are
released and an iterator referencing the failed lock is returned.
If any of the __try_lock_ref__ operations on the supplied
__lockable_concept_type__ objects throws an exception any locks
acquired by the function will be released before the function exits.]]
[[Returns:] [`end` if all the supplied __lockable_concept_type__
objects are now locked by the calling thread, an iterator referencing
the object which could not be locked otherwise.]]
[[Throws:] [Any exceptions thrown by calling __try_lock_ref__ on the
supplied __lockable_concept_type__ objects.]]
[[Postcondition:] [If the function returns `end` then all the
__lockable_concept_type__ objects in the supplied range are locked by
the calling thread, otherwise all locks acquired by the function have
been released.]]
]
[endsect]
[endsect]
[section:lock_factories Lock Factories - EXTENSION]
namespace boost
{
template <typename Lockable>
unique_lock<Lockable> make_unique_lock(Lockable& mtx); // EXTENSION
template <typename Lockable>
unique_lock<Lockable> make_unique_lock(Lockable& mtx, adopt_lock_t); // EXTENSION
template <typename Lockable>
unique_lock<Lockable> make_unique_lock(Lockable& mtx, defer_lock_t); // EXTENSION
template <typename Lockable>
unique_lock<Lockable> make_unique_lock(Lockable& mtx, try_to_lock_t); // EXTENSION
#if ! defined(BOOST_THREAD_NO_MAKE_UNIQUE_LOCKS)
template <typename ...Lockable>
std::tuple<unique_lock<Lockable> ...> make_unique_locks(Lockable& ...mtx); // EXTENSION
#endif
}
[section:make_unique_lock Non Member Function `make_unique_lock(Lockable&)`]
template <typename Lockable>
unique_lock<Lockable> make_unique_lock(Lockable& mtx); // EXTENSION
[variablelist
[[Returns:] [a __unique_lock as if initialized with `unique_lock<Lockable>(mtx)`.]]
[[Throws:] [Any exception thrown by the call to `__unique_lock<Lockable>(mtx)`.]]
]
[endsect]
[section:make_unique_lock_t Non Member Function `make_unique_lock(Lockable&,tag)`]
template <typename Lockable>
unique_lock<Lockable> make_unique_lock(Lockable& mtx, adopt_lock_t tag); // EXTENSION
template <typename Lockable>
unique_lock<Lockable> make_unique_lock(Lockable& mtx, defer_lock_t tag); // EXTENSION
template <typename Lockable>
unique_lock<Lockable> make_unique_lock(Lockable& mtx, try_to_lock_t tag); // EXTENSION
[variablelist
[[Returns:] [a __unique_lock as if initialized with `unique_lock<Lockable>(mtx, tag)`.]]
[[Throws:] [Any exception thrown by the call to `__unique_lock<Lockable>(mtx, tag)`.]]
]
[endsect]
[section:make_unique_locks Non Member Function `make_unique_locks(Lockable& ...)`]
template <typename ...Lockable>
std::tuple<unique_lock<Lockable> ...> make_unique_locks(Lockable& ...mtx); // EXTENSION
[variablelist
[[Effect:] [Locks all the mutexes.]]
[[Returns:] [a std::tuple of unique __unique_lock owning each one of the mutex.]]
[[Throws:] [Any exception thrown by `boost::lock(mtx...)`.]]
]
[endsect]
[endsect]
|