diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-08-12 21:57:15 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-08-12 21:57:15 +0800 |
commit | ad144ad2e4220dcbf678c515e4670c094413ea6d (patch) | |
tree | 830a273bfd288f828167c5445ba15bcd1050c98e /test/bls_c384_test.cpp | |
parent | aa867dd6770e7956ff08bff55639a4f4d1d74910 (diff) | |
download | dexon-bls-ad144ad2e4220dcbf678c515e4670c094413ea6d.tar.gz dexon-bls-ad144ad2e4220dcbf678c515e4670c094413ea6d.tar.zst dexon-bls-ad144ad2e4220dcbf678c515e4670c094413ea6d.zip |
add blsInitThreadSafe
Diffstat (limited to 'test/bls_c384_test.cpp')
-rw-r--r-- | test/bls_c384_test.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/bls_c384_test.cpp b/test/bls_c384_test.cpp index 8c3761f..2e61e2c 100644 --- a/test/bls_c384_test.cpp +++ b/test/bls_c384_test.cpp @@ -62,6 +62,46 @@ void blsOrderTest(const char *curveOrder, const char *fieldOrder) CYBOZU_TEST_EQUAL(buf, fieldOrder); } +#if CYBOZU_CPP_VERSION >= CYBOZU_CPP_VERSION_CPP11 +#include <thread> +#include <vector> +struct Thread { + std::unique_ptr<std::thread> t; + Thread() : t() {} + ~Thread() + { + if (t) { + t->join(); + } + } + template<class F> + void run(F func, int p1, int p2) + { + t.reset(new std::thread(func, p1, p2)); + } +}; +CYBOZU_TEST_AUTO(multipleInit) +{ + const size_t n = 100; + { + std::vector<Thread> vt(n); + for (size_t i = 0; i < n; i++) { + vt[i].run(blsInitThreadSafe, mclBn_CurveFp254BNb, MCLBN_FP_UNIT_SIZE); + } + } + CYBOZU_TEST_EQUAL(blsGetOpUnitSize(), 4u); +#if MCLBN_FP_UNIT_SIZE == 6 + { + std::vector<Thread> vt(n); + for (size_t i = 0; i < n; i++) { + vt[i].run(blsInitThreadSafe, mclBn_CurveFp382_1, MCLBN_FP_UNIT_SIZE); + } + } + CYBOZU_TEST_EQUAL(blsGetOpUnitSize(), 6u); +#endif +} +#endif + CYBOZU_TEST_AUTO(all) { const int tbl[] = { |