msgid ""
msgstr ""
"Project-Id-Version: Chinese (Simplified Han script) (Boost Unordered "
"Translation (zh_Hans))\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-06-06 22:46+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Chinese (Simplified Han script) <https://"
"insights.cppalliance.org/weblate/projects/boost-unordered-documentation-"
"zh_Hans/doc-modules-root-pages-concurrent-adoc/zh_Hans/>\n"
"Language: zh_Hans\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 2026.5\n"

#: :1
#, safe-html, strict-same
msgid "﻿[#concurrent] = Concurrent Containers"
msgstr "= 并发容器"

#: :4
#, safe-html, strict-same
msgid ":idprefix: concurrent_"
msgstr ":idprefix: concurrent_"

#: :6
#, safe-html, strict-same
msgid ""
"Boost.Unordered provides `boost::concurrent_node_set`, "
"`boost::concurrent_node_map`, `boost::concurrent_flat_set` and "
"`boost::concurrent_flat_map`, hash tables that allow concurrent write/read "
"access from different threads without having to implement any synchronzation "
"mechanism on the user's side."
msgstr ""
"Boost.Unordered 提供 `boost::concurrent_node_set` 、 "
"`boost::concurrent_node_map` 、 `boost::concurrent_flat_set` 和 "
"`boost::concurrent_flat_map` ，这些哈希表允许不同线程进行并发读写访问，无需用"
"户实现任何同步机制。"

#: :36
#, safe-html, strict-same
msgid ""
"In the example above, threads access `m` without synchronization, just as "
"we'd do in a single-threaded scenario. In an ideal setting, if a given "
"workload is distributed among _N_ threads, execution is _N_ times faster "
"than with one thread —this limit is never attained in practice due to "
"synchronization overheads and _contention_ (one thread waiting for another "
"to leave a locked portion of the map), but Boost.Unordered concurrent "
"containers are designed to perform with very little overhead and typically "
"achieve _linear scaling_ (that is, performance is proportional to the number "
"of threads up to the number of logical cores in the CPU)."
msgstr ""
"在上例中，线程无需同步即可访问 `m` ，这与单线程场景中的操作方式一致。在理想情"
"况下，若将给定工作负载分配给 _N_ 个线程，其执行速度相较单线程提升 _N_ 倍——由"
"于同步开销与__争用__的存在（某线程等待其他线程离开容器的锁定区域），实践中无"
"法达到此理论极限。但 Boost.Unordered 并发容器设计为以极低开销运行，通常可实"
"现__线性扩展__（即性能提升与线程数量成正比，直至达到 CPU 的逻辑核心数）。"

#: :45
#, safe-html, strict-same
msgid "Visitation-based API"
msgstr "基于访问的 API"

#: :47
#, safe-html, strict-same
msgid ""
"The first thing a new user of Boost.Unordered concurrent containers will "
"notice is that these classes _do not provide iterators_ (which makes them "
"technically not https://en.cppreference.com/w/cpp/named_req/"
"Container[Containers^] in the C++ standard sense). The reason for this is "
"that iterators are inherently thread-unsafe. Consider this hypothetical code:"
msgstr ""
"Boost.Unordered 并发容器的新用户首先会注意到：这些类__不提供迭代器__（它们在"
"技术层面上不符合 C{plus}{plus} 标准中的 https://en.cppreference.com/w/cpp/"
"named_req/Container[容器] 定义）。因为迭代器本质上是线程不安全的。请参考以下"
"假设代码："

#: :61
#, safe-html, strict-same
msgid ""
"In a multithreaded scenario, the iterator `it` may be invalid at point B if "
"some other thread issues an `m.erase(k)` operation between A and B. There "
"are designs that can remedy this by making iterators lock the element they "
"point to, but this approach lends itself to high contention and can easily "
"produce deadlocks in a program. `operator[]` has similar concurrency issues, "
"and is not provided by `boost::concurrent_flat_map`/"
"`boost::concurrent_node_map` either. Instead, element access is done through "
"so-called _visitation functions_:"
msgstr ""
"多线程场景中，若其他线程在 A 和 B 之间执行 `m.erase(k)` 操作，迭代器 `it` 可"
"能在 B 点失效。虽然存在通过锁定指向元素来修复此问题的设计方案，但这种方法容易"
"引发高竞争并可能导致程序死锁。 `operator++[]++` 也存在类似并发问题，因此 "
"`boost::concurrent++_++flat++_++map` / `boost::concurrent++_++node++_++map` "
"也未提供该操作。替代方案是通过__访问函数__操作元素："

#: :76
#, safe-html, strict-same
msgid ""
"The visitation function passed by the user (in this case, a lambda function) "
"is executed internally by Boost.Unordered in a thread-safe manner, so it can "
"access the element without worrying about other threads interfering in the "
"process."
msgstr ""
"用户传递的访问函数（此处为 lambda 函数）由 Boost.Unordered 在内部以线程安全的"
"方式执行，因此该函数可以安全访问目标元素，无需担心其他线程在此过程中造成干扰"
"。"

#: :81
#, safe-html, strict-same
msgid ""
"On the other hand, a visitation function can _not_ access the container "
"itself:"
msgstr "另一方面，访问函数__无法__访问容器本身："

#: :90
#, safe-html, strict-same
msgid "Access to a different container is allowed, though:"
msgstr "但允许访问其他容器："

#: :101
#, safe-html, strict-same
msgid ""
"But, in general, visitation functions should be as lightweight as possible "
"to reduce contention and increase parallelization. In some cases, moving "
"heavy work outside of visitation may be beneficial:"
msgstr ""
"但通常而言，访问函数应尽可能轻量以减少争用并提升并行性。在某些情况下，将繁重"
"操作移出访问函数可能更优："

#: :116
#, safe-html, strict-same
msgid ""
"Visitation is prominent in the API provided by concurrent containers, and "
"many classical operations have visitation-enabled variations:"
msgstr ""
"访问机制在并发容器 API 中占据核心地位，许多经典操作都提供了支持访问机制的变体"
"："

#: :128
#, safe-html, strict-same
msgid ""
"Note that in this last example the visitation function could actually "
"_modify_ the element: as a general rule, operations on a concurrent map `m` "
"will grant visitation functions const/non-const access to  the element "
"depending on whether `m` is const/non-const. Const access can be always be "
"explicitly requested by using `cvisit` overloads (for instance, "
"`insert_or_cvisit`) and may result in higher parallelization. For concurrent "
"sets, on the other hand, visitation is always const access."
msgstr ""
"注意此例中访问函数可__修改__元素：作为通用规则，对并发映射 `m` 的操作将根据 "
"`m` 是否为常量类型，授予访问函数对元素的常量/非常量访问权限。 通过使用 "
"`cvisit` 重载（如 `insert++_++or++_++cvisit` ）可始终显式请求常量访问，这可能"
"提升并行性。而并发集合的访问始终为常量访问。"

#: :136
#, safe-html, strict-same
msgid ""
"Although expected to be used much less frequently, concurrent containers "
"also provide insertion operations where an element can be visited right "
"after element creation (in addition to the usual visitation when an "
"equivalent element already exists):"
msgstr ""
"尽管预期使用频率较低，并发容器还提供在元素创建后立即进行访问的插入操作（除在"
"已存在等价元素时执行常规访问之外）："

#: :152
#, safe-html, strict-same
msgid ""
"Consult the references of `xref:reference/"
"concurrent_node_set.adoc#concurrent_node_set[boost::concurrent_node_set]`, "
"`xref:reference/"
"concurrent_node_map.adoc#concurrent_node_map[boost::concurrent_node_map]`, "
"`xref:reference/"
"concurrent_flat_set.adoc#concurrent_flat_set[boost::concurrent_flat_set]` "
"and `xref:reference/"
"concurrent_flat_map.adoc#concurrent_flat_map[boost::concurrent_flat_map]` "
"for the complete list of visitation-enabled operations."
msgstr ""
"支持访问功能的完整操作列表请参阅 xref:reference/"
"concurrent_node_set.adoc#concurrent_node_set[`boost::concurrent++_++node++_++set`] "
"、 xref:reference/"
"concurrent_node_map.adoc#concurrent_node_map[`boost::concurrent++_++node++_++map`] "
"、 xref:reference/"
"concurrent_flat_set.adoc#concurrent_flat_set[`boost::concurrent++_++flat++_++set`] "
"和 xref:reference/"
"concurrent_flat_map.adoc#concurrent_flat_map[`boost::concurrent++_++flat++_++map`] "
"的参考文档。"

#: :159
#, safe-html, strict-same
msgid "Whole-Table Visitation"
msgstr "全表访问"

#: :161
#, safe-html, strict-same
msgid ""
"In the absence of iterators, `visit_all` is provided as an alternative way "
"to process all the elements in the container:"
msgstr "在缺乏迭代器的情况下， `visit++_++all` 提供处理容器内全部元素的替代方案："

#: :171
#, safe-html, strict-same
msgid ""
"In C++17 compilers implementing standard parallel algorithms, whole-table "
"visitation can be parallelized:"
msgstr "在支持标准并行算法的 C{plus}{plus}17 编译器中，全表遍历访问可进行并行化处理："

#: :181
#, safe-html, strict-same
msgid "Traversal can be interrupted midway:"
msgstr "遍历过程可中途中断："

#: :202
#, safe-html, strict-same
msgid "There is one last whole-table visitation operation, `erase_if`:"
msgstr "最后一项全表访问操作是 `erase++_++if` ："

#: :211
#, safe-html, strict-same
msgid ""
"`visit_while` and `erase_if` can also be parallelized. Note that, in order "
"to increase efficiency, whole-table visitation operations do not block the "
"table during execution: this implies that elements may be inserted, modified "
"or erased by other threads during visitation. It is advisable not to assume "
"too much about the exact global state of a concurrent container at any point "
"in your program."
msgstr ""
"`visit++_++while` 与 `erase++_++if` 同样支持并行化。需要注意的是，为提升执行"
"效率，全表遍历操作在运行期间不会锁定整个容器：这意味着在遍历过程中，其他线程"
"可能同时执行元素的插入、修改或删除操作。建议在程序中避免对并发容器在任意时间"
"点的全局状态做过强的假设。"

#: :217
#, safe-html, strict-same
msgid "Bulk visitation"
msgstr "批量访问"

#: :219
#, safe-html, strict-same
msgid ""
"Suppose you have an `std::array` of keys you want to look up for in a "
"concurrent map:"
msgstr "假设有一个 `std::array` 存储了需要在并发映射中查找的键："

#: :230
#, safe-html, strict-same
msgid "_Bulk visitation_ allows us to pass all the keys in one operation:"
msgstr "__批量访问__允许用户通过单次操作传入所有键："

#: :237
#, safe-html, strict-same
msgid ""
"This functionality is not provided for mere syntactic convenience, though: "
"by processing all the keys at once, some internal optimizations can be "
"applied that increase performance over the regular, one-at-a-time case "
"(consult the "
"xref:benchmarks.adoc#benchmarks_boostconcurrent_flatnode_map[benchmarks]). "
"In fact, it may be beneficial to buffer incoming keys so that they can be "
"bulk visited in chunks:"
msgstr ""
"提供此功能并非仅出于语法便利性考量：通过一次性处理所有键，可应用内部优化提升"
"性能（详见 xref:benchmarks.adoc#benchmarks_boostconcurrent_flatnode_map[基准"
"测试]）。实际上，用户可通过缓冲输入键值以实现分块批量访问，从而进一步提升效率"
"："

#: :261
#, safe-html, strict-same
msgid ""
"There's a latency/throughput tradeoff here: it will take longer for incoming "
"keys to be processed (since they are buffered), but the number of processed "
"keys per second is higher. `bulk_visit_size` is the recommended chunk size —"
"smaller buffers may yield worse performance."
msgstr ""
"这里存在延迟与吞吐量的权衡：缓冲机制会延长单个键的处理延迟，但每秒处理的键总"
"数（吞吐量）会更高。 `bulk++_++visit++_++size` 是推荐的缓冲区块大小——过小的缓"
"冲区可能导致性能下降。"

#: :266
#, safe-html, strict-same
msgid "Blocking Operations"
msgstr "阻塞式操作"

#: :268
#, safe-html, strict-same
msgid ""
"Concurrent containers can be copied, assigned, cleared and merged just like "
"any other Boost.Unordered container. Unlike most other operations, these are "
"_blocking_, that is, all other threads are prevented from accesing the "
"tables involved while a copy, assignment, clear or merge operation is in "
"progress. Blocking is taken care of automatically by the library and the "
"user need not take any special precaution, but overall performance may be "
"affected."
msgstr ""
"并发容器可像其他 Boost.Unordered 容器一样支持复制、赋值、清空和合并操作。与大"
"多数其他操作不同，这些属于__阻塞式操作__：在执行期间，其他线程将被阻止访问相"
"关容器。该阻塞机制由库自动处理，用户无需采取特殊预防措施，但整体性能可能受到"
"影响。"

#: :274
#, safe-html, strict-same
msgid ""
"Another blocking operation is _rehashing_, which happens explicitly via "
"`rehash`/`reserve` or during insertion when the table's load hits `max_load()"
"`. As with non-concurrent containers, reserving space in advance of bulk "
"insertions will generally speed up the process."
msgstr ""
"另一阻塞操作是__重哈希__，该操作可通过 `rehash` / `reserve` 显式触发，或在插"
"入过程中当容器负载达到 `max++_++load()` 时自动执行。与非并发容器类似，在批量"
"插入前预先分配空间通常能加速处理过程。"

#: :278
#, safe-html, strict-same
msgid "Interoperability with non-concurrent containers"
msgstr "与非并发容器的互操作性"

#: :280
#, safe-html, strict-same
msgid ""
"As open-addressing and concurrent containers are based on the same internal "
"data structure, they can be efficiently move-constructed from their non-"
"concurrent counterpart, and vice versa."
msgstr ""
"由于开放寻址容器与并发容器基于相同的内部数据结构，它们可以高效地通过移动构造"
"从其非并发对应容器转换而来，反之亦然。"

#: :286
#, safe-html, strict-same
msgid "^|`boost::concurrent_node_set` ^|`boost::unordered_node_set`"
msgstr "^|`boost::concurrent_node_set` ^|`boost::unordered_node_set`"

#: :289
#, safe-html, strict-same
msgid "^|`boost::concurrent_node_map` ^|`boost::unordered_node_map`"
msgstr "^|`boost::concurrent_node_map` ^|`boost::unordered_node_map`"

#: :292
#, safe-html, strict-same
msgid "^|`boost::concurrent_flat_set` ^|`boost::unordered_flat_set`"
msgstr "^|`boost::concurrent_flat_set` ^|`boost::unordered_flat_set`"

#: :295
#, safe-html, strict-same
msgid "^|`boost::concurrent_flat_map` ^|`boost::unordered_flat_map`"
msgstr "^|`boost::concurrent_flat_set` ^|`boost::unordered_flat_set`"

#: :300
#, safe-html, strict-same
msgid ""
"This interoperability comes handy in multistage scenarios where parts of the "
"data processing happen in parallel whereas other steps are non-concurrent "
"(or non-modifying). In the following example, we want to construct a "
"histogram from a huge input vector of words: the population phase can be "
"done in parallel with `boost::concurrent_flat_map` and results then "
"transferred to the final container."
msgstr ""
"此互操作性适用于多阶段场景：部分数据处理环节需要并行执行，而其他步骤采用非并"
"发（或只读）模式。下例中，我们需要从一个庞大的单词输入向量构建词频统计直方图"
"：填充阶段用 `boost::concurrent++_++flat++_++map` 并行执行，随后将结果转移至"
"最终容器。"
