Convert job_list to a dequeue again

Now that we have cleaned up access to the job list and removed
transparent invalidation of iterators, it is safe to convert it to a
dequeue.
This commit is contained in:
Mahmoud Al-Qudsi 2018-12-30 23:53:26 -06:00
parent f8e0e0ef82
commit 6fab783647
3 changed files with 5 additions and 5 deletions

View file

@ -580,7 +580,7 @@ void parser_t::job_promote(job_t *job) {
assert(loc != my_job_list.end());
// Move the job to the beginning.
my_job_list.splice(my_job_list.begin(), my_job_list, loc);
std::rotate(my_job_list.begin(), loc, my_job_list.end());
}
job_t *parser_t::job_get(job_id_t id) {

View file

@ -475,7 +475,7 @@ static bool process_clean_after_marking(bool allow_interactive) {
bool erased = false;
const bool only_one_job = jobs().size() == 1;
for (auto itr = jobs().begin(); itr != jobs().end(); itr = (erased ? itr : (std::advance(itr, 1), itr)), erased = false) {
for (auto itr = jobs().begin(); itr != jobs().end(); itr = erased ? itr : itr + 1, erased = false) {
job_t *j = itr->get();
// If we are reaping only jobs who do not need status messages sent to the console, do not
// consider reaping jobs that need status messages.

View file

@ -12,7 +12,7 @@
#include <termios.h>
#include <unistd.h>
#include <list>
#include <deque>
#include <memory>
#include <vector>
@ -451,8 +451,8 @@ extern bool is_login;
/// nesting level.
extern int is_event;
// List of jobs. We sometimes mutate this while iterating - hence it must be a list, not a vector
typedef std::list<shared_ptr<job_t>> job_list_t;
// List of jobs.
typedef std::deque<shared_ptr<job_t>> job_list_t;
bool job_list_is_empty(void);