mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-05-17 20:09:46 +00:00
fix tread pool crashed
This commit is contained in:
parent
1093323f64
commit
4abcd137bf
@ -48,10 +48,15 @@ void KeysReactor::handleGenerateNewKeys() {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
QtConcurrent::run(generatorFunc, QRSAEncryption::RSA_64);
|
_futures.insert(QRSAEncryption::RSA_64,
|
||||||
QtConcurrent::run(generatorFunc, QRSAEncryption::RSA_128);
|
QtConcurrent::run(generatorFunc, QRSAEncryption::RSA_64));
|
||||||
QtConcurrent::run(generatorFunc, QRSAEncryption::RSA_256);
|
_futures.insert(QRSAEncryption::RSA_128,
|
||||||
QtConcurrent::run(generatorFunc, QRSAEncryption::RSA_512);
|
QtConcurrent::run(generatorFunc, QRSAEncryption::RSA_128));
|
||||||
|
_futures.insert(QRSAEncryption::RSA_256,
|
||||||
|
QtConcurrent::run(generatorFunc, QRSAEncryption::RSA_256));
|
||||||
|
_futures.insert(QRSAEncryption::RSA_512,
|
||||||
|
QtConcurrent::run(generatorFunc, QRSAEncryption::RSA_512));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,5 +82,8 @@ KeysReactor::KeysReactor(bool ForceGenerateKey, QObject *ptr):
|
|||||||
}
|
}
|
||||||
|
|
||||||
KeysReactor::~KeysReactor() {
|
KeysReactor::~KeysReactor() {
|
||||||
|
for (auto && i: _futures) {
|
||||||
|
i.cancel();
|
||||||
|
i.waitForFinished();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ private:
|
|||||||
ClientProtocol::RSAKeysPool _pool;
|
ClientProtocol::RSAKeysPool _pool;
|
||||||
int _poolSize = DEFAULT_KEYPOOL_SIZE;
|
int _poolSize = DEFAULT_KEYPOOL_SIZE;
|
||||||
QHash<QRSAEncryption::Rsa, bool> _mutexs;
|
QHash<QRSAEncryption::Rsa, bool> _mutexs;
|
||||||
|
QHash<QRSAEncryption::Rsa, QFuture<void>> _futures;
|
||||||
void generateKeys(QRSAEncryption::Rsa);
|
void generateKeys(QRSAEncryption::Rsa);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user