Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. // regex.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include <regex>
  6. #include <map>
  7.  
  8. #include <future>
  9. #include <thread>
  10.  
  11. #include "spdlog/spdlog.h"
  12. #include "spdlog/sinks/basic_file_sink.h"
  13. #include "spdlog/sinks/rotating_file_sink.h"
  14.  
  15. void parallelBot(std::promise<bool> &&prom)
  16. {
  17.  
  18.  
  19. //connect to twitch
  20. spdlog::critical("beep boop");
  21. auto couldEstablishConnectionToTwitch = []() {return true; };
  22.  
  23.  
  24. if (couldEstablishConnectionToTwitch()) // true
  25. {
  26. prom.set_value(true);
  27. }
  28. else
  29. {
  30. spdlog::error("bo...ooo....p....");
  31. prom.set_value(false);
  32. }
  33. }
  34.  
  35. int main()
  36. {
  37. auto my_logger = spdlog::basic_logger_mt("basic_logger", "logs/log.txt");
  38. spdlog::set_default_logger(my_logger);
  39.  
  40.  
  41. std::promise<bool> connectionPromise;
  42. auto isConnnected = connectionPromise.get_future();
  43.  
  44. std::thread twitchThread{ &parallelBot, std::move(connectionPromise) };
  45.  
  46. // ...
  47. // do stuff
  48. // ...
  49.  
  50.  
  51. twitchThread.join();
  52.  
  53. if (bool isConnected = false; isConnected = isConnnected.get()) // true
  54. {
  55. // hier
  56. spdlog::info("BEEP BOOP!!!");
  57. }
  58. else
  59. {
  60. spdlog::info("no BEEP BOOP :( ");
  61. }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement