Added mutex
This commit is contained in:
parent
08a7cb1988
commit
44f1692e80
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.7)
|
||||
project (expandurl-mastodon
|
||||
VERSION 0.2.6
|
||||
VERSION 0.3.0
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <fstream>
|
||||
#include <cstdlib> // getenv()
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include "version.hpp"
|
||||
#include "expandurl-mastodon.hpp"
|
||||
|
||||
|
@ -65,6 +66,10 @@ const void Listener::start()
|
|||
cout << "DEBUG: Connection lost.\n";
|
||||
_running = false;
|
||||
});
|
||||
while (_ptr == nullptr)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
}
|
||||
|
||||
const void Listener::stop()
|
||||
|
@ -85,6 +90,7 @@ std::vector<Easy::Notification> Listener::get_new_messages()
|
|||
std::vector<Easy::Notification> v;
|
||||
static std::uint_fast8_t count_empty = 0;
|
||||
|
||||
std::lock_guard<std::mutex> lock(_ptr->get_mutex());
|
||||
if (!_stream.empty())
|
||||
{
|
||||
const string buffer = _stream;
|
||||
|
|
Loading…
Reference in New Issue