Polling of available printers in now asynchronous (#264,#256)
- Increased polling interval from 1s to 10s - Use QtConcurrent::run to initiate a poll asynchronously to main event loop - Do not initiate a poll if the previous poll has not completed - Use copies instead of references to mCurrentAvailablePrinters in public API
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
#define PrinterMonitor_h
|
||||
|
||||
|
||||
#include <QFuture>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
@@ -53,7 +55,7 @@ namespace glabels
|
||||
// Public methods
|
||||
/////////////////////////////////
|
||||
public:
|
||||
const QStringList& availablePrinters() const;
|
||||
QStringList availablePrinters();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -67,7 +69,14 @@ namespace glabels
|
||||
// Signals
|
||||
/////////////////////////////////
|
||||
signals:
|
||||
void availablePrintersChanged( const QStringList& availablePrinters );
|
||||
void availablePrintersChanged( QStringList availablePrinters );
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
// Private methods
|
||||
/////////////////////////////////
|
||||
private:
|
||||
void asyncPoll();
|
||||
|
||||
|
||||
/////////////////////////////////
|
||||
@@ -77,8 +86,11 @@ namespace glabels
|
||||
static std::unique_ptr<PrinterMonitor> mInstance;
|
||||
|
||||
std::unique_ptr<QTimer> mTimer;
|
||||
|
||||
QStringList mCurrentAvailablePrinters;
|
||||
QMutex mCurrentAvailablePrintersMutex;
|
||||
|
||||
QFuture<void> mPollStatus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user