mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 12:52:29 +03:00
38d790cac0
The code uses two mechanisms for generating random numbers: srand()/rand(), which is not thread-safe, and srandom()/random(), which is POSIX-specific. Here I add a util/random.cc module that centralizes these calls, and unifies some common usage patterns. If the implementation is not good enough, we can now change it in a single place. To keep things simple, this uses the portable srand()/rand() but protects them with a lock to avoid concurrency problems. The hard part was to keep the regression tests passing: they rely on fixed sequences of random numbers, so a small code change could break them very thoroughly. Util::rand(), for wide types like size_t, calls std::rand() not once but twice. This behaviour was generalized into utils::wide_rand() and friends. |
||
---|---|---|
.. | ||
Loader.h | ||
LoaderCompact.cpp | ||
LoaderCompact.h | ||
LoaderFactory.cpp | ||
LoaderFactory.h | ||
LoaderHiero.cpp | ||
LoaderHiero.h | ||
LoaderStandard.cpp | ||
LoaderStandard.h | ||
PhraseDictionaryALSuffixArray.cpp | ||
PhraseDictionaryALSuffixArray.h | ||
PhraseDictionaryFuzzyMatch.cpp | ||
PhraseDictionaryFuzzyMatch.h | ||
PhraseDictionaryOnDisk.cpp | ||
PhraseDictionaryOnDisk.h | ||
Trie.cpp | ||
Trie.h | ||
UTrie.cpp | ||
UTrie.h | ||
UTrieNode.cpp | ||
UTrieNode.h |