[pan2/testing: 144/279] [*] reverted max connections back to 4 to keep GNKSA [+] only max_connection instances of encoder ru
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 144/279] [*] reverted max connections back to 4 to keep GNKSA [+] only max_connection instances of encoder ru
- Date: Sat, 3 Dec 2011 22:34:16 +0000 (UTC)
commit 4380266128b3578108a3e95815529c55818b8330
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Sun Jul 3 18:52:15 2011 +0200
[*] reverted max connections back to 4 to keep GNKSA
[+] only max_connection instances of encoder run at the same time, encoding in realtime
[+] added statusbar to upload queue (total bytes, total tasks, selectable)
pan/gui/post-ui.cc | 105 +++++++++++++++++++++++++++++++++++++-------
pan/gui/post-ui.h | 10 ++++-
pan/gui/server-ui.cc | 2 +-
pan/tasks/queue.cc | 75 ++++++++++++++++++--------------
pan/tasks/queue.h | 6 ++-
pan/tasks/task-upload.cc | 2 +-
pan/tasks/task-upload.h | 9 ++--
pan/tasks/upload-queue.cc | 2 +-
8 files changed, 151 insertions(+), 60 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index caddaf9..f07e72d 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -134,6 +134,34 @@ namespace
}
}
+/***
+****
+***/
+
+void
+PostUI:: update_filequeue_label (GtkTreeSelection *selection)
+{
+ PostUI::tasks_t tasks(get_selected_files());
+
+ if (tasks.empty())
+ _upload_queue.get_all_tasks(tasks);
+
+ char str[512];
+ long kb(0);
+ foreach (PostUI::tasks_t, tasks, it)
+ {
+ TaskUpload * task (*it);
+ kb += task->_bytes/1024;
+ }
+ g_snprintf(str,sizeof(str), _("Upload Queue : %d Tasks, %ld KB (~ %.2f MB) total ."), tasks.size(), kb, kb/1024.0f);
+ gtk_label_set_text (GTK_LABEL(_filequeue_label), str);
+}
+
+/***
+****
+***/
+
+/* only used if the encode mode has changed, would be too expensive for repetitive calls */
void
PostUI :: update_filequeue_tab()
{
@@ -178,6 +206,8 @@ PostUI :: on_queue_tasks_added (UploadQueue& queue, int index, int count)
4, task->encode_mode().c_str(),
-1);
}
+
+ update_filequeue_label();
}
void
@@ -190,6 +220,8 @@ PostUI :: on_queue_task_removed (UploadQueue&, TaskUpload& task, int index)
GtkTreeIter iter;
gtk_tree_model_iter_nth_child (GTK_TREE_MODEL(store), &iter, NULL, index);
gtk_list_store_remove (store, &iter);
+
+ update_filequeue_label();
}
void
@@ -474,28 +506,41 @@ namespace
}
gboolean
+PostUI :: on_selection_changed (GtkTreeSelection *s,gpointer p)
+{
+ static_cast<PostUI*>(p)->update_filequeue_label();
+}
+
+gboolean
PostUI :: on_button_pressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
- {
- if (event->type == GDK_BUTTON_PRESS && event->button == 3)
+{
+
+ if (event->type == GDK_BUTTON_PRESS )
{
GtkTreeSelection *selection;
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
- if (gtk_tree_selection_count_selected_rows(selection) <= 1)
+
+ if ( event->button == 3)
{
- GtkTreePath *path;
- /* Get tree path for row that was clicked */
- if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
- (gint) event->x,
- (gint) event->y,
- &path, NULL, NULL, NULL))
- {
- gtk_tree_selection_unselect_all(selection);
- gtk_tree_selection_select_path(selection, path);
- gtk_tree_path_free(path);
- }
+
+ if (gtk_tree_selection_count_selected_rows(selection) <= 1)
+ {
+ GtkTreePath *path;
+ /* Get tree path for row that was clicked */
+ if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
+ (gint) event->x,
+ (gint) event->y,
+ &path, NULL, NULL, NULL))
+ {
+ gtk_tree_selection_unselect_all(selection);
+ gtk_tree_selection_select_path(selection, path);
+ gtk_tree_path_free(path);
+ }
+ }
+ do_popup_menu(treeview, event, userdata);
+ return TRUE;
}
- do_popup_menu(treeview, event, userdata);
- return TRUE;
+
}
return FALSE;
}
@@ -2345,6 +2390,7 @@ PostUI :: create_filequeue_tab ()
//set hint and selection
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(w),TRUE);
GtkTreeSelection * selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (w));
+ g_signal_connect (selection, "changed", G_CALLBACK(on_selection_changed), this);
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(w));
@@ -2355,9 +2401,31 @@ PostUI :: create_filequeue_tab ()
gtk_container_add (GTK_CONTAINER(w), _filequeue_store);
gtk_box_pack_start (GTK_BOX(vbox), w, true, true, 0);
+ // add status bar
+ gtk_box_pack_start (GTK_BOX(vbox), create_filequeue_status_bar(), false, false, 0);
+ update_filequeue_label ();
+
return vbox;
}
+GtkWidget*
+PostUI:: create_filequeue_status_bar ()
+{
+ GtkWidget * w;
+ GtkWidget * status_bar (gtk_hbox_new (FALSE, 0));
+
+ // connection status
+ w = _filequeue_label = gtk_label_new (NULL);
+ gtk_misc_set_padding (GTK_MISC(w), PAD, 0);
+ GtkWidget * frame = gtk_frame_new (NULL);
+ gtk_container_set_border_width (GTK_CONTAINER(frame), 0);
+ gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
+ gtk_container_add (GTK_CONTAINER(frame), w);
+ gtk_box_pack_start (GTK_BOX(status_bar), frame, FALSE, FALSE, 0);
+
+ return status_bar;
+}
+
void
PostUI:: on_parts_box_clicked_cb (GtkCellRendererToggle *cell, gchar *path_str, gpointer user_data)
{
@@ -2645,6 +2713,7 @@ void
PostUI :: clear_list (void)
{
_upload_queue.clear();
+ update_filequeue_label();
}
void PostUI :: up_clicked_cb (GtkButton*, PostUI* pane)
@@ -2811,7 +2880,9 @@ PostUI :: PostUI (GtkWindow * parent,
_draft_autosave_timeout(0),
_draft_autosave_idle_tag(0),
_body_changed_id(0),
- _body_changed_idle_tag(0)
+ _body_changed_idle_tag(0),
+ _filequeue_eventbox (0),
+ _filequeue_label (0)
{
mtrand.seed();
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index 5878566..105f7bc 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -105,6 +105,7 @@ namespace pan
static void do_popup_menu (GtkWidget*, GdkEventButton *event, gpointer pane_g);
static gboolean on_button_pressed (GtkWidget * treeview, GdkEventButton *event, gpointer userdata);
+ static gboolean on_selection_changed (GtkTreeSelection *s,gpointer p);
private:
void done_sending_message (GMimeMessage*, bool);
@@ -189,10 +190,17 @@ namespace pan
GtkWidget* create_main_tab ();
GtkWidget* create_extras_tab ();
GtkWidget* create_filequeue_tab ();
- void update_filequeue_tab();
+
+ GtkWidget* create_filequeue_status_bar ();
+ GtkWidget * _filequeue_eventbox;
+ GtkWidget * _filequeue_label;
+ void update_filequeue_label (GtkTreeSelection *selection=NULL);
+
GtkWidget* create_parts_tab ();
GtkWidget* create_log_tab ();
+ void update_filequeue_tab();
+
private:
std::string utf8ize (const StringView&) const;
std::string get_body () const;
diff --git a/pan/gui/server-ui.cc b/pan/gui/server-ui.cc
index 6870b7d..a118661 100644
--- a/pan/gui/server-ui.cc
+++ b/pan/gui/server-ui.cc
@@ -252,7 +252,7 @@ pan :: server_edit_dialog_new (Data& data, Queue& queue, GtkWindow * window, con
HIG::workarea_add_section_spacer (t, row, 2);
// max connections
- const int DEFAULT_MAX_PER_SERVER (20);
+ const int DEFAULT_MAX_PER_SERVER (4);
a = GTK_ADJUSTMENT (gtk_adjustment_new (1.0, 0.0, DEFAULT_MAX_PER_SERVER, 1.0, 1.0, 0.0));
d->connection_limit_spin = w = gtk_spin_button_new (GTK_ADJUSTMENT(a), 1.0, 0u);
HIG::workarea_add_row (t, &row, _("Connection _Limit:"), w, NULL);
diff --git a/pan/tasks/queue.cc b/pan/tasks/queue.cc
index 698c0d1..8d5aeae 100644
--- a/pan/tasks/queue.cc
+++ b/pan/tasks/queue.cc
@@ -49,7 +49,7 @@ Queue :: Queue (ServerInfo & server_info,
_needs_saving (false),
_last_time_saved (0),
_archive (archive),
- _current_uploads(0)
+ _uploads_total(0)
{
tasks_t tasks;
_archive.load_tasks (tasks);
@@ -112,18 +112,14 @@ Queue :: get_pool (const Quark& servername)
void
Queue :: clean_n_save ()
{
+
const tasks_t tmp (_tasks.begin(), _tasks.end());
// remove completed tasks.
foreach_const (tasks_t, tmp, it) {
Task * task (*it);
const Task::State& state (task->get_state());
if (state._work==Task::COMPLETED || _removing.count(task))
- {
- TaskUpload* t = dynamic_cast<TaskUpload*>(task);
- if (task)
- --_current_uploads;
remove_task (task);
- }
}
// maybe save the task list.
@@ -150,7 +146,7 @@ Queue :: upkeep ()
// ref #352170, #354779
foreach_const (tasks_t, tmp, it) {
Task * task (*it);
- if (task->get_state()._work == Task::NEED_NNTP) {
+ if (task->get_state()._work == Task::NEED_NNTP ) {
process_task (task);
break;
}
@@ -164,6 +160,10 @@ Queue :: upkeep ()
foreach (std::set<Task*>, active, it)
process_task (*it);
+ //upkeep on paused upload slots
+// foreach (std::set<TaskUpload*>, _uploads, it)
+// process_task (*it);
+
// idle socket upkeep
foreach (pools_t, _pools, it)
it->second->idle_upkeep ();
@@ -246,9 +246,22 @@ Queue :: give_task_a_connection (Task * task, NNTP * nntp)
}
void
+Queue :: give_task_an_upload_slot (TaskUpload* task)
+{
+ int max (_server_info.get_server_limits(task->_server));
+ if (_uploads.size() < max)
+ {
+ _uploads.insert(task);
+ task->wakeup();
+ fire_task_active_changed (task, true);
+ process_task(task);
+ }
+}
+
+void
Queue :: process_task (Task * task)
{
- pan_return_if_fail (task!=0);
+ pan_return_if_fail (task != 0);
debug ("in process_task with a task of type " << task->get_type());
@@ -257,9 +270,6 @@ Queue :: process_task (Task * task)
if (state._work == Task::COMPLETED)
{
debug ("completed");
- TaskUpload* t = dynamic_cast<TaskUpload*>(task);
- if (task)
- --_current_uploads;
remove_task (task);
}
else if (_removing.count(task))
@@ -280,15 +290,12 @@ Queue :: process_task (Task * task)
else if (state._work == Task::WORKING)
{
debug ("working");
- // do nothing
}
else if (state._work == Task::PAUSED)
{
- std::cerr<<"paused task\n";
- debug ("paused");
- const Task::State::unique_servers_t& servers (state._servers);
- foreach_const (Task::State::unique_servers_t, servers, it)
- request_wakeup ((TaskUpload*)task,*it);
+ TaskUpload* t = dynamic_cast<TaskUpload*>(task);
+ if (t)
+ give_task_an_upload_slot(t);
}
else if (state._work == Task::NEED_DECODER)
{
@@ -368,19 +375,6 @@ Queue :: find_first_task_needing_server (const Quark& server)
return 0;
}
-void
-Queue :: request_wakeup (TaskUpload* task, const Quark& server)
-{
- int max (_server_info.get_server_limits(server));
- std::cerr<<"request wakeup "<<_current_uploads<<" "<<max<<std::endl;
- if (_current_uploads < max)
- {
- std::cerr<<"task wakeup ("<<max<<"(!\n";
- ++_current_uploads;
- task->wakeup();
- }
-}
-
bool
Queue :: find_best_server (const Task::State::unique_servers_t& servers, Quark& setme)
{
@@ -614,10 +608,27 @@ Queue :: remove_task (Task * task)
TaskArticle * ta (dynamic_cast<TaskArticle*>(task));
if (ta)
_mids.erase (ta->get_article().message_id);
-
_stopped.erase (task);
_removing.erase (task);
_tasks.remove (index);
+
+ // manually upkeep on ONE new taskupload to keep the queue going
+ TaskUpload * t (dynamic_cast<TaskUpload*>(task));
+ if (t)
+ {
+ int max (_server_info.get_server_limits(t->_server));
+ _uploads.erase(t);
+ const tasks_t tmp (_tasks.begin(), _tasks.end());
+ foreach_const (tasks_t, tmp, it) {
+ Task * task (*it);
+ if (task->get_state()._work == Task::PAUSED)
+ {
+ give_task_an_upload_slot(dynamic_cast<TaskUpload*>(*it));
+ break;
+ }
+ }
+ }
+
delete task;
}
@@ -731,7 +742,7 @@ Queue :: check_in (Decoder* decoder UNUSED, Task* task)
}
void
-Queue :: check_in (Encoder* decoder UNUSED, Task* task)
+Queue :: check_in (Encoder* encoder UNUSED, Task* task)
{
// take care of our decoder counting...
_encoder_task = 0;
diff --git a/pan/tasks/queue.h b/pan/tasks/queue.h
index e1bd4ae..b97d2c9 100644
--- a/pan/tasks/queue.h
+++ b/pan/tasks/queue.h
@@ -190,7 +190,7 @@ namespace pan
Task* find_first_task_needing_decoder ();
Task* find_first_task_needing_encoder ();
- void request_wakeup (TaskUpload* task, const Quark& server);
+ void give_task_an_upload_slot (TaskUpload* task);
bool find_best_server (const Task::State::unique_servers_t& servers, Quark& setme);
bool task_is_active (const Task*) const;
@@ -198,6 +198,7 @@ namespace pan
typedef std::map<NNTP*,Task*> nntp_to_task_t;
nntp_to_task_t _nntp_to_task;
+ std::set<TaskUpload*> _uploads;
std::set<Task*> _removing;
std::set<Task*> _stopped;
Socket::Creator * _socket_creator;
@@ -235,12 +236,13 @@ namespace pan
bool _needs_saving;
time_t _last_time_saved;
quarks_t _mids;
- int _current_uploads;
private:
TaskArchive& _archive;
void clean_n_save ();
+ int _uploads_total;
+
private:
typedef AdaptableSet<Task*, TaskWeakOrdering> TaskSet;
TaskSet _tasks;
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 2beafd9..184fc80 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -133,7 +133,7 @@ TaskUpload :: update_work (NNTP* checkin_pending)
}
/* only need encode if mode is NOT plain */
- if (!_encoder && !_encoder_has_run && _msg)
+ if (!_encoder && !_encoder_has_run)
{
_state.set_need_encoder();
}
diff --git a/pan/tasks/task-upload.h b/pan/tasks/task-upload.h
index 5530a84..8bcd1f7 100644
--- a/pan/tasks/task-upload.h
+++ b/pan/tasks/task-upload.h
@@ -152,8 +152,7 @@ namespace pan
private: // implementation
friend class Encoder;
friend class PostUI;
- friend class NZB;
- friend class MyContext;
+ friend class Queue;
Encoder * _encoder;
bool _encoder_has_run;
std::string _filename;
@@ -171,16 +170,16 @@ namespace pan
Article::mid_sequence_t _mids;
int _queue_pos;
int _lpf;
- needed_t _needed;
+ needed_t _needed;
void update_work (NNTP * checkin_pending = 0);
public:
void build_needed_tasks();
- std::set<int> _wanted;
- void wakeup() { update_work(); }
+ void wakeup() { _state.set_working(); update_work(); }
private:
+ std::set<int> _wanted;
GMimeMessage * _msg;
void prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::string& d);
diff --git a/pan/tasks/upload-queue.cc b/pan/tasks/upload-queue.cc
index db71848..d77d2a2 100644
--- a/pan/tasks/upload-queue.cc
+++ b/pan/tasks/upload-queue.cc
@@ -40,7 +40,7 @@ UploadQueue :: UploadQueue ()
UploadQueue :: ~UploadQueue ()
{
- //deletion is done by main queue.
+ //deletion is done by main queue in PostUI.
// const tasks_t tmp (_tasks.begin(), _tasks.end());
// foreach_const (tasks_t, tmp, it) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]