~mzanetti/reminders-app/edit-note-improvements

« back to all changes in this revision

Viewing changes to src/libqtevernote/evernoteconnection.h

Further improve the jobqueue by splitting it up into high, medium and low priority queues and optimizing the reply rate.

Approved by Ubuntu Phone Apps Jenkins Bot, Riccardo Padovani.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
    QString token() const;
74
74
    void setToken(const QString &token);
75
75
 
 
76
    // This will add the job to the job queue. The job queue will take ownership of the object
 
77
    // and manage it's lifetime.
 
78
    // * If there is an identical job already existing in the queue, the duplicate will be
 
79
    //   attached to original job and not actually fetched a second time from the network in
 
80
    //   order to reduce network traffic.
 
81
    // * If the new job has a higher priority than the existing one, the existing one will
 
82
    //   reprioritized to the higher priorty.
 
83
    // * If the jobs have different originatingObjects, each job will emit the jobDone signal,
 
84
    //   if instead the originatingObject is the same in both jobs, only one of them will emit
 
85
    //   a jobDone signal. This is useful if you want to reschedule a job with higher priority
 
86
    //   without having to track previously queued jobs and avoid invoking the connected slot
 
87
    //   multiple times.
76
88
    void enqueue(EvernoteJob *job);
77
89
 
78
90
    bool isConnected() const;
104
116
    bool connectUserStore();
105
117
    bool connectNotesStore();
106
118
 
107
 
    EvernoteJob* findDuplicate(EvernoteJob *job);
 
119
    EvernoteJob* findExistingDuplicate(EvernoteJob *job);
 
120
 
 
121
    // "duplicate" will be attached to "original"
 
122
    void attachDuplicate(EvernoteJob *original, EvernoteJob *duplicate);
108
123
 
109
124
    bool m_useSSL;
110
125
    bool m_isConnected;
115
130
 
116
131
    // There must be only one job running at a time
117
132
    // Do not start jobs other than with startJobQueue()
118
 
    QList<EvernoteJob*> m_jobQueue;
 
133
    QList<EvernoteJob*> m_highPriorityJobQueue;
 
134
    QList<EvernoteJob*> m_mediumPriorityJobQueue;
 
135
    QList<EvernoteJob*> m_lowPriorityJobQueue;
119
136
    EvernoteJob *m_currentJob;
120
137
 
121
138
    // Those need to be mutexed