changed window closing unref main lock strategy - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/gsl-shell.c
diff options
context:
space:
mode:
authorfrancesco-ST <francesco.abbate@st.com>2010年12月28日 16:52:42 +0100
committerfrancesco-ST <francesco.abbate@st.com>2010年12月28日 16:52:42 +0100
commitab7fc91161b8cb493b418bfdd2871e45c4537a26 (patch)
treeea400f746489d587d153f0b6b6677c6a17bf916f /gsl-shell.c
parent978986bb98f1ae622be3f430f4e729fbb598afb8 (diff)
downloadgsl-shell-ab7fc91161b8cb493b418bfdd2871e45c4537a26.tar.gz
changed window closing unref main lock strategy
A global lock is used now to guard the main loop. The plot windows directly unrefs the window by just waiting the main lock. Simplified also the window index code since plot are not indexed since many versions now. The windows are not explicitely closed when the main loop terminates.
Diffstat (limited to 'gsl-shell.c')
-rw-r--r--gsl-shell.c 86
1 files changed, 11 insertions, 75 deletions
diff --git a/gsl-shell.c b/gsl-shell.c
index 84fb16d8..928c8020 100644
--- a/gsl-shell.c
+++ b/gsl-shell.c
@@ -64,23 +64,8 @@
#include "lua-gsl.h"
#include "lua-utils.h"
-#ifdef AGG_PLOT_ENABLED
-#include "object-index.h"
-#include "window.h"
-#endif
-
#define report error_report
-struct window_unref_cell {
- int id;
- struct window_unref_cell *next;
-};
-
-#define UNREF_FIXED_SIZE 8
-static int unref_fixed_list[UNREF_FIXED_SIZE];
-static size_t unref_fixed_count = 0;
-
-static struct window_unref_cell *window_unref_list = NULL;
static lua_State *globalL = NULL;
static const char *progname = LUA_PROGNAME;
@@ -285,8 +270,13 @@ static int pushline (lua_State *L, int firstline) {
char *b = buffer;
size_t l;
const char *prmt = get_prompt(L, firstline);
+ int ok;
- if (lua_readline(L, b, prmt) == 0)
+ GSL_SHELL_UNLOCK();
+ ok = lua_readline(L, b, prmt);
+ GSL_SHELL_LOCK();
+
+ if (ok == 0)
{
return 0; /* no input */
}
@@ -335,35 +325,12 @@ static int loadline (lua_State *L) {
return status;
}
-static void do_windows_unref (lua_State *L)
-{
- struct window_unref_cell *wu;
- size_t j;
-
- GSL_SHELL_LOCK();
-
- for (j = 0; j < unref_fixed_count; j++)
- {
- object_index_remove (L, OBJECT_WINDOW, unref_fixed_list[j]);
- }
-
- unref_fixed_count = 0;
-
- for (wu = window_unref_list; wu != NULL; /* */)
- {
- struct window_unref_cell *nxt = wu->next;
- object_index_remove (L, OBJECT_WINDOW, wu->id);
- free (wu);
- wu = nxt;
- }
- window_unref_list = NULL;
-
- GSL_SHELL_UNLOCK();
-}
-
static void dotty (lua_State *L) {
const char *oldprogname = progname;
progname = NULL;
+
+ GSL_SHELL_LOCK();
+
for (;;)
{
int status = loadline(L);
@@ -384,24 +351,12 @@ static void dotty (lua_State *L) {
l_message(progname, emsg);
}
}
-
-#ifdef AGG_PLOT_ENABLED
- do_windows_unref (L);
-#endif
}
-#ifdef AGG_PLOT_ENABLED
- object_index_apply_all (L, OBJECT_WINDOW, window_close);
-
- do
- {
- do_windows_unref (L);
- }
- while (object_index_count (L, OBJECT_WINDOW) > 0);
-#endif
-
lua_settop(L, 0); /* clear stack */
+ GSL_SHELL_UNLOCK();
+
fputs("\n", stdout);
fflush(stdout);
progname = oldprogname;
@@ -589,22 +544,3 @@ int main (int argc, char **argv) {
return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
}
-
-void
-gsl_shell_unref_plot (int id)
-{
- if (unref_fixed_count < UNREF_FIXED_SIZE)
- {
- unref_fixed_list[unref_fixed_count] = id;
- unref_fixed_count ++;
- }
- else
- {
- struct window_unref_cell *cell = malloc(sizeof(struct window_unref_cell));
-
- cell->id = id;
- cell->next = window_unref_list;
-
- window_unref_list = cell;
- }
-}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月30日 14:07:52 +0000

AltStyle によって変換されたページ (->オリジナル) /