improve threads interaction
This commit is contained in:
parent
8e73104f28
commit
87fd44e644
|
|
@ -119,7 +119,7 @@ do_update() {
|
|||
for (int tc = 0; tc < num_toplevel_collectors; tc++) {
|
||||
int collector = client_data->get_toplevel_collector(tc);
|
||||
if (client_data->has_collector(collector) &&
|
||||
client_data->get_collector_has_level(collector)) {
|
||||
client_data->get_collector_has_level(collector, _thread_index)) {
|
||||
|
||||
// We put a separator between the above frame collector and the
|
||||
// first level collector.
|
||||
|
|
|
|||
|
|
@ -42,9 +42,8 @@ const GdkColor GtkStatsGraph::rgb_user_guide_bar = {
|
|||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
GtkStatsGraph::
|
||||
GtkStatsGraph(GtkStatsMonitor *monitor, int thread_index) :
|
||||
_monitor(monitor),
|
||||
_thread_index(thread_index)
|
||||
GtkStatsGraph(GtkStatsMonitor *monitor) :
|
||||
_monitor(monitor)
|
||||
{
|
||||
_parent_window = NULL;
|
||||
_window = NULL;
|
||||
|
|
@ -146,17 +145,6 @@ GtkStatsGraph::
|
|||
gtk_widget_destroy(_window);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GtkStatsGraph::get_thread_index
|
||||
// Access: Public
|
||||
// Description: Returns the thread index associated with this
|
||||
// particular graph.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int GtkStatsGraph::
|
||||
get_thread_index() const {
|
||||
return _thread_index;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: GtkStatsGraph::new_collector
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -45,11 +45,9 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
GtkStatsGraph(GtkStatsMonitor *monitor, int thread_index);
|
||||
GtkStatsGraph(GtkStatsMonitor *monitor);
|
||||
virtual ~GtkStatsGraph();
|
||||
|
||||
int get_thread_index() const;
|
||||
|
||||
virtual void new_collector(int collector_index);
|
||||
virtual void new_data(int thread_index, int frame_number);
|
||||
virtual void force_redraw();
|
||||
|
|
@ -81,7 +79,6 @@ protected:
|
|||
Brushes _brushes;
|
||||
|
||||
GtkStatsMonitor *_monitor;
|
||||
int _thread_index;
|
||||
GtkWidget *_parent_window;
|
||||
GtkWidget *_window;
|
||||
GtkWidget *_graph_window;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ GtkStatsPianoRoll(GtkStatsMonitor *monitor, int thread_index) :
|
|||
PStatPianoRoll(monitor, thread_index,
|
||||
default_piano_roll_width,
|
||||
default_piano_roll_height),
|
||||
GtkStatsGraph(monitor, thread_index)
|
||||
GtkStatsGraph(monitor)
|
||||
{
|
||||
// Let's show the units on the guide bar labels. There's room.
|
||||
set_guide_bar_units(get_guide_bar_units() | GBU_show_units);
|
||||
|
|
@ -52,6 +52,12 @@ GtkStatsPianoRoll(GtkStatsMonitor *monitor, int thread_index) :
|
|||
gtk_widget_set_size_request(_graph_window, default_piano_roll_width,
|
||||
default_piano_roll_height);
|
||||
|
||||
const PStatClientData *client_data =
|
||||
GtkStatsGraph::_monitor->get_client_data();
|
||||
string thread_name = client_data->get_thread_name(_thread_index);
|
||||
string window_title = thread_name + " thread piano roll";
|
||||
gtk_window_set_title(GTK_WINDOW(_window), window_title.c_str());
|
||||
|
||||
gtk_widget_show_all(_window);
|
||||
gtk_widget_show(_window);
|
||||
|
||||
|
|
@ -137,7 +143,7 @@ set_time_units(int unit_mask) {
|
|||
void GtkStatsPianoRoll::
|
||||
clicked_label(int collector_index) {
|
||||
if (collector_index >= 0) {
|
||||
GtkStatsGraph::_monitor->open_strip_chart(GtkStatsGraph::_thread_index, collector_index, false);
|
||||
GtkStatsGraph::_monitor->open_strip_chart(_thread_index, collector_index, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -418,7 +424,7 @@ update_labels() {
|
|||
_label_stack.clear_labels();
|
||||
for (int i = 0; i < get_num_labels(); i++) {
|
||||
_label_stack.add_label(GtkStatsGraph::_monitor, this,
|
||||
GtkStatsGraph::_thread_index,
|
||||
_thread_index,
|
||||
get_label_collector(i), true);
|
||||
}
|
||||
_labels_changed = false;
|
||||
|
|
|
|||
|
|
@ -34,10 +34,11 @@ GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index,
|
|||
int collector_index, bool show_level) :
|
||||
PStatStripChart(monitor,
|
||||
show_level ? monitor->get_level_view(collector_index, thread_index) : monitor->get_view(thread_index),
|
||||
thread_index,
|
||||
collector_index,
|
||||
default_strip_chart_width,
|
||||
default_strip_chart_height),
|
||||
GtkStatsGraph(monitor, thread_index)
|
||||
GtkStatsGraph(monitor)
|
||||
{
|
||||
_brush_origin = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -161,21 +161,21 @@ get_collector_fullname(int index) const {
|
|||
// otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PStatClientData::
|
||||
set_collector_has_level(int index, bool flag) {
|
||||
set_collector_has_level(int index, int thread_index, bool flag) {
|
||||
bool any_changed = false;
|
||||
slot_collector(index);
|
||||
nassertr(index >= 0 && index < (int)_collectors.size(), false);
|
||||
|
||||
if (_collectors[index]._is_level != flag) {
|
||||
if (_collectors[index]._is_level.get_bit(thread_index) != flag) {
|
||||
any_changed = true;
|
||||
_collectors[index]._is_level = flag;
|
||||
_collectors[index]._is_level.set_bit_to(thread_index, flag);
|
||||
|
||||
// Turning this on for a given collector also implicitly turns all
|
||||
// of its ancestors.
|
||||
if (flag) {
|
||||
PStatCollectorDef *def = _collectors[index]._def;
|
||||
if (def->_parent_index != 0) {
|
||||
set_collector_has_level(def->_parent_index, flag);
|
||||
set_collector_has_level(def->_parent_index, thread_index, flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -192,9 +192,9 @@ set_collector_has_level(int index, bool flag) {
|
|||
// Levels menu).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PStatClientData::
|
||||
get_collector_has_level(int index) const {
|
||||
get_collector_has_level(int index, int thread_index) const {
|
||||
return (index >= 0 && index < (int)_collectors.size() &&
|
||||
_collectors[index]._is_level);
|
||||
_collectors[index]._is_level.get_bit(thread_index));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -327,8 +327,12 @@ add_collector(PStatCollectorDef *def) {
|
|||
|
||||
// If we already had the _is_level flag set, it should be
|
||||
// immediately applied to all ancestors.
|
||||
if (_collectors[def->_index]._is_level) {
|
||||
set_collector_has_level(def->_parent_index, true);
|
||||
const BitArray &is_level = _collectors[def->_index]._is_level;
|
||||
int max_threads = is_level.get_num_bits();
|
||||
for (int thread_index = 0; thread_index < max_threads; ++thread_index) {
|
||||
if (is_level.get_bit(thread_index)) {
|
||||
set_collector_has_level(def->_parent_index, thread_index, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +395,6 @@ slot_collector(int collector_index) {
|
|||
while ((int)_collectors.size() <= collector_index) {
|
||||
Collector collector;
|
||||
collector._def = (PStatCollectorDef *)NULL;
|
||||
collector._is_level = false;
|
||||
_collectors.push_back(collector);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "pStatClientVersion.h"
|
||||
#include "referenceCount.h"
|
||||
#include "pointerTo.h"
|
||||
#include "bitArray.h"
|
||||
|
||||
#include "pvector.h"
|
||||
#include "vector_int.h"
|
||||
|
|
@ -51,8 +52,8 @@ public:
|
|||
const PStatCollectorDef &get_collector_def(int index) const;
|
||||
string get_collector_name(int index) const;
|
||||
string get_collector_fullname(int index) const;
|
||||
bool set_collector_has_level(int index, bool flag);
|
||||
bool get_collector_has_level(int index) const;
|
||||
bool set_collector_has_level(int index, int thread_index, bool flag);
|
||||
bool get_collector_has_level(int index, int thread_index) const;
|
||||
|
||||
int get_num_toplevel_collectors() const;
|
||||
int get_toplevel_collector(int index) const;
|
||||
|
|
@ -81,7 +82,7 @@ private:
|
|||
class Collector {
|
||||
public:
|
||||
PStatCollectorDef *_def;
|
||||
bool _is_level;
|
||||
BitArray _is_level;
|
||||
};
|
||||
|
||||
typedef pvector<Collector> Collectors;
|
||||
|
|
|
|||
|
|
@ -75,8 +75,10 @@ protected:
|
|||
private:
|
||||
void compute_page(const PStatFrameData &frame_data);
|
||||
|
||||
protected:
|
||||
int _thread_index;
|
||||
|
||||
private:
|
||||
float _time_width;
|
||||
float _start_time;
|
||||
|
||||
|
|
|
|||
|
|
@ -314,10 +314,10 @@ dequeue_frame_data() {
|
|||
int num_levels = data._frame_data->get_num_levels();
|
||||
for (int i = 0; i < num_levels; i++) {
|
||||
int collector_index = data._frame_data->get_level_collector(i);
|
||||
if (!_client_data->get_collector_has_level(collector_index)) {
|
||||
if (!_client_data->get_collector_has_level(collector_index, data._thread_index)) {
|
||||
// This collector is now reporting level data, and it wasn't
|
||||
// before.
|
||||
_client_data->set_collector_has_level(collector_index, true);
|
||||
_client_data->set_collector_has_level(collector_index, data._thread_index, true);
|
||||
_monitor->new_collector(collector_index);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,9 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
PStatStripChart::
|
||||
PStatStripChart(PStatMonitor *monitor, PStatView &view,
|
||||
int collector_index, int xsize, int ysize) :
|
||||
int thread_index, int collector_index, int xsize, int ysize) :
|
||||
PStatGraph(monitor, xsize, ysize),
|
||||
_thread_index(thread_index),
|
||||
_view(view),
|
||||
_collector_index(collector_index)
|
||||
{
|
||||
|
|
@ -280,7 +281,6 @@ get_title_text() {
|
|||
string text;
|
||||
|
||||
_title_unknown = false;
|
||||
int _thread_index = 0;
|
||||
|
||||
const PStatClientData *client_data = _monitor->get_client_data();
|
||||
if (client_data->has_collector(_collector_index)) {
|
||||
|
|
@ -299,7 +299,7 @@ get_title_text() {
|
|||
|
||||
if (_thread_index != 0) {
|
||||
if (client_data->has_thread(_thread_index)) {
|
||||
text += "(" + client_data->get_thread_name(_thread_index) + " thread)";
|
||||
text += " (" + client_data->get_thread_name(_thread_index) + " thread)";
|
||||
} else {
|
||||
_title_unknown = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class PStatView;
|
|||
class PStatStripChart : public PStatGraph {
|
||||
public:
|
||||
PStatStripChart(PStatMonitor *monitor, PStatView &view,
|
||||
int collector_index, int xsize, int ysize);
|
||||
int thread_index, int collector_index, int xsize, int ysize);
|
||||
virtual ~PStatStripChart();
|
||||
|
||||
void new_data(int frame_number);
|
||||
|
|
@ -124,6 +124,10 @@ private:
|
|||
void dec_label_usage(const FrameData &fdata);
|
||||
void inc_label_usage(const FrameData &fdata);
|
||||
|
||||
protected:
|
||||
int _thread_index;
|
||||
|
||||
private:
|
||||
PStatView &_view;
|
||||
int _collector_index;
|
||||
bool _scroll_mode;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ new_data(int thread_index, int frame_number) {
|
|||
for (int tc = 0; tc < num_toplevel_collectors; tc++) {
|
||||
int collector = client_data->get_toplevel_collector(tc);
|
||||
if (client_data->has_collector(collector) &&
|
||||
client_data->get_collector_has_level(collector)) {
|
||||
client_data->get_collector_has_level(collector, thread_index)) {
|
||||
|
||||
PStatView &level_view = get_level_view(collector, thread_index);
|
||||
level_view.set_to_frame(frame_number);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ do_update() {
|
|||
for (int tc = 0; tc < num_toplevel_collectors; tc++) {
|
||||
int collector = client_data->get_toplevel_collector(tc);
|
||||
if (client_data->has_collector(collector) &&
|
||||
client_data->get_collector_has_level(collector)) {
|
||||
client_data->get_collector_has_level(collector, _thread_index)) {
|
||||
|
||||
// We put a separator between the above frame collector and the
|
||||
// first level collector.
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@ WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_VISIBLE;
|
|||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
WinStatsGraph::
|
||||
WinStatsGraph(WinStatsMonitor *monitor, int thread_index) :
|
||||
_monitor(monitor),
|
||||
_thread_index(thread_index)
|
||||
WinStatsGraph(WinStatsMonitor *monitor) :
|
||||
_monitor(monitor)
|
||||
{
|
||||
_window = 0;
|
||||
_graph_window = 0;
|
||||
|
|
@ -93,17 +92,6 @@ WinStatsGraph::
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: WinStatsGraph::get_thread_index
|
||||
// Access: Public
|
||||
// Description: Returns the thread index associated with this
|
||||
// particular graph.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int WinStatsGraph::
|
||||
get_thread_index() const {
|
||||
return _thread_index;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: WinStatsGraph::new_collector
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -47,11 +47,9 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
WinStatsGraph(WinStatsMonitor *monitor, int thread_index);
|
||||
WinStatsGraph(WinStatsMonitor *monitor);
|
||||
virtual ~WinStatsGraph();
|
||||
|
||||
int get_thread_index() const;
|
||||
|
||||
virtual void new_collector(int collector_index);
|
||||
virtual void new_data(int thread_index, int frame_number);
|
||||
virtual void force_redraw();
|
||||
|
|
@ -90,7 +88,6 @@ protected:
|
|||
Brushes _brushes;
|
||||
|
||||
WinStatsMonitor *_monitor;
|
||||
int _thread_index;
|
||||
HWND _window;
|
||||
HWND _graph_window;
|
||||
WinStatsLabelStack _label_stack;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ WinStatsPianoRoll(WinStatsMonitor *monitor, int thread_index) :
|
|||
PStatPianoRoll(monitor, thread_index,
|
||||
default_piano_roll_width,
|
||||
default_piano_roll_height),
|
||||
WinStatsGraph(monitor, thread_index)
|
||||
WinStatsGraph(monitor)
|
||||
{
|
||||
_left_margin = 128;
|
||||
_right_margin = 8;
|
||||
|
|
@ -127,7 +127,7 @@ set_time_units(int unit_mask) {
|
|||
void WinStatsPianoRoll::
|
||||
clicked_label(int collector_index) {
|
||||
if (collector_index >= 0) {
|
||||
WinStatsGraph::_monitor->open_strip_chart(WinStatsGraph::_thread_index, collector_index, false);
|
||||
WinStatsGraph::_monitor->open_strip_chart(_thread_index, collector_index, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ update_labels() {
|
|||
for (int i = 0; i < get_num_labels(); i++) {
|
||||
int label_index =
|
||||
_label_stack.add_label(WinStatsGraph::_monitor, this,
|
||||
WinStatsGraph::_thread_index,
|
||||
_thread_index,
|
||||
get_label_collector(i), true);
|
||||
}
|
||||
_labels_changed = false;
|
||||
|
|
@ -562,7 +562,7 @@ create_window() {
|
|||
|
||||
const PStatClientData *client_data =
|
||||
WinStatsGraph::_monitor->get_client_data();
|
||||
string thread_name = client_data->get_thread_name(WinStatsGraph::_thread_index);
|
||||
string thread_name = client_data->get_thread_name(_thread_index);
|
||||
string window_title = thread_name + " thread piano roll";
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,11 @@ WinStatsStripChart(WinStatsMonitor *monitor, int thread_index,
|
|||
int collector_index, bool show_level) :
|
||||
PStatStripChart(monitor,
|
||||
show_level ? monitor->get_level_view(collector_index, thread_index) : monitor->get_view(thread_index),
|
||||
thread_index,
|
||||
collector_index,
|
||||
default_strip_chart_width,
|
||||
default_strip_chart_height),
|
||||
WinStatsGraph(monitor, thread_index)
|
||||
WinStatsGraph(monitor)
|
||||
{
|
||||
_brush_origin = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue