Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.217.144.32] |
|
Страницы: (3) 1 2 [3] все ( Перейти к последнему сообщению ) |
Сообщ.
#31
,
|
|
|
ну использовать вот так можно: #include "Logger.h" #include <iostream> #include <thread> #include <vector> #include <algorithm> void Test(core::Logger& logger, const std::wstring& message) { int counter = 1; while (counter < 10000) { logger.Log() << core::log::warning << L" " << core::log::thread << L" " << message << L" counter: " << counter << std::endl; ++counter; } } int main() { core::Logger logger(L"main.log"); std::wstring msg1 = L"This is message one"; std::wstring msg2 = L"This is message two"; std::wstring msg3 = L"This is message three"; std::vector<std::thread> threads; threads.emplace_back(Test, std::ref(logger), std::ref(msg1)); threads.emplace_back(Test, std::ref(logger), std::ref(msg2)); threads.emplace_back(Test, std::ref(logger), std::ref(msg3)); std::for_each(threads.begin(), threads.end(), [](auto&& item) { item.join(); }); std::cout << "Done..."; std::cin.get(); return 0; } |