Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // regex.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include <iostream>
- #include <regex>
- #include <map>
- #include <future>
- #include <thread>
- #include "spdlog/spdlog.h"
- #include "spdlog/sinks/basic_file_sink.h"
- #include "spdlog/sinks/rotating_file_sink.h"
- void parallelBot(std::promise<bool> &&prom)
- {
- //connect to twitch
- spdlog::critical("beep boop");
- auto couldEstablishConnectionToTwitch = []() {return true; };
- if (couldEstablishConnectionToTwitch()) // true
- {
- prom.set_value(true);
- }
- else
- {
- spdlog::error("bo...ooo....p....");
- prom.set_value(false);
- }
- }
- int main()
- {
- auto my_logger = spdlog::basic_logger_mt("basic_logger", "logs/log.txt");
- spdlog::set_default_logger(my_logger);
- std::promise<bool> connectionPromise;
- auto isConnnected = connectionPromise.get_future();
- std::thread twitchThread{ ¶llelBot, std::move(connectionPromise) };
- // ...
- // do stuff
- // ...
- twitchThread.join();
- if (bool isConnected = false; isConnected = isConnnected.get()) // true
- {
- // hier
- spdlog::info("BEEP BOOP!!!");
- }
- else
- {
- spdlog::info("no BEEP BOOP :( ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement