mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
make connectionMutex QMutex into a std::mutex
This commit is contained in:
parent
880fe7e81c
commit
2d2d6dad17
2 changed files with 12 additions and 11 deletions
|
@ -159,7 +159,7 @@ void IrcManager::beginConnecting()
|
|||
Communi::IrcConnection *_writeConnection = this->createConnection(false);
|
||||
Communi::IrcConnection *_readConnection = this->createConnection(true);
|
||||
|
||||
QMutexLocker locker(&_connectionMutex);
|
||||
std::lock_guard<std::mutex> locker(this->connectionMutex);
|
||||
|
||||
if (generation == this->connectionGeneration) {
|
||||
this->writeConnection = std::shared_ptr<Communi::IrcConnection>(_writeConnection);
|
||||
|
@ -183,7 +183,7 @@ void IrcManager::beginConnecting()
|
|||
|
||||
void IrcManager::disconnect()
|
||||
{
|
||||
_connectionMutex.lock();
|
||||
this->connectionMutex.lock();
|
||||
|
||||
auto _readConnection = this->readConnection;
|
||||
auto _writeConnection = this->writeConnection;
|
||||
|
@ -191,43 +191,43 @@ void IrcManager::disconnect()
|
|||
this->readConnection.reset();
|
||||
this->writeConnection.reset();
|
||||
|
||||
_connectionMutex.unlock();
|
||||
this->connectionMutex.unlock();
|
||||
}
|
||||
|
||||
void IrcManager::sendMessage(const QString &channelName, const QString &message)
|
||||
{
|
||||
_connectionMutex.lock();
|
||||
this->connectionMutex.lock();
|
||||
|
||||
if (this->writeConnection) {
|
||||
this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + message);
|
||||
}
|
||||
|
||||
_connectionMutex.unlock();
|
||||
this->connectionMutex.unlock();
|
||||
}
|
||||
|
||||
void IrcManager::joinChannel(const QString &channelName)
|
||||
{
|
||||
_connectionMutex.lock();
|
||||
this->connectionMutex.lock();
|
||||
|
||||
if (this->readConnection && this->writeConnection) {
|
||||
this->readConnection->sendRaw("JOIN #" + channelName);
|
||||
this->writeConnection->sendRaw("JOIN #" + channelName);
|
||||
}
|
||||
|
||||
_connectionMutex.unlock();
|
||||
this->connectionMutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
void IrcManager::partChannel(const QString &channelName)
|
||||
{
|
||||
_connectionMutex.lock();
|
||||
this->connectionMutex.lock();
|
||||
|
||||
if (this->readConnection && this->writeConnection) {
|
||||
this->readConnection->sendRaw("PART #" + channelName);
|
||||
this->writeConnection->sendRaw("PART #" + channelName);
|
||||
}
|
||||
|
||||
_connectionMutex.unlock();
|
||||
this->connectionMutex.unlock();
|
||||
}
|
||||
|
||||
void IrcManager::messageReceived(Communi::IrcMessage *message)
|
||||
|
@ -239,8 +239,8 @@ void IrcManager::messageReceived(Communi::IrcMessage *message)
|
|||
qDebug() << "Param: " << param;
|
||||
}
|
||||
|
||||
const QString &command = message->command();
|
||||
/*
|
||||
const QString &command = message->command();
|
||||
|
||||
if (command == "CLEARCHAT") {
|
||||
} else if (command == "ROOMSTATE") {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
@ -56,7 +57,7 @@ private:
|
|||
std::shared_ptr<Communi::IrcConnection> writeConnection = nullptr;
|
||||
std::shared_ptr<Communi::IrcConnection> readConnection = nullptr;
|
||||
|
||||
QMutex _connectionMutex;
|
||||
std::mutex connectionMutex;
|
||||
uint32_t connectionGeneration = 0;
|
||||
|
||||
QMap<QString, bool> _twitchBlockedUsers;
|
||||
|
|
Loading…
Reference in a new issue