diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2011-01-26 01:54:56 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2011-01-26 01:54:56 +0000 |
commit | db7a89b1ee4c11006cdf607465b6c0fc13333fd1 (patch) | |
tree | 5a6f12be811cd9f6ca649d23fcd4a482c5458b09 /tmux.h | |
parent | 4dfb29fa38a22615eda253b1124261379f6fbbcc (diff) | |
download | rtmux-db7a89b1ee4c11006cdf607465b6c0fc13333fd1.tar.gz rtmux-db7a89b1ee4c11006cdf607465b6c0fc13333fd1.tar.bz2 rtmux-db7a89b1ee4c11006cdf607465b6c0fc13333fd1.zip |
Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.
Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.
This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).
Diffstat (limited to 'tmux.h')
-rw-r--r-- | tmux.h | 33 |
1 files changed, 16 insertions, 17 deletions
@@ -671,8 +671,6 @@ struct job { pid_t pid; int status; - struct client *client; - int fd; struct bufferevent *event; @@ -680,13 +678,8 @@ struct job { void (*freefn)(void *); void *data; - int flags; -#define JOB_PERSIST 0x1 /* don't free after callback */ - - RB_ENTRY(job) entry; LIST_ENTRY(job) lentry; }; -RB_HEAD(jobs, job); LIST_HEAD(joblist, job); /* Screen selection. */ @@ -1091,6 +1084,15 @@ struct message_entry { time_t msg_time; }; +/* Status output data from a job. */ +struct status_out { + char *cmd; + char *out; + + RB_ENTRY(status_out) entry; +}; +RB_HEAD(status_out_tree, status_out); + /* Client connection. */ struct client { struct imsgbuf ibuf; @@ -1120,8 +1122,9 @@ struct client { struct event repeat_timer; + struct status_out_tree status_old; + struct status_out_tree status_new; struct timeval status_timer; - struct jobs status_jobs; struct screen status; #define CLIENT_TERMINAL 0x1 @@ -1363,18 +1366,10 @@ const char *options_table_print_entry( /* job.c */ extern struct joblist all_jobs; -int job_cmp(struct job *, struct job *); -RB_PROTOTYPE(jobs, job, entry, job_cmp); -void job_tree_init(struct jobs *); -void job_tree_free(struct jobs *); -struct job *job_get(struct jobs *, const char *); -struct job *job_add(struct jobs *, int, struct client *, +struct job *job_run( const char *, void (*)(struct job *), void (*)(void *), void *); -void job_remove(struct jobs *, struct job *); void job_free(struct job *); -int job_run(struct job *); void job_died(struct job *, int); -void job_kill(struct job *); /* environ.c */ int environ_cmp(struct environ_entry *, struct environ_entry *); @@ -1660,6 +1655,10 @@ void server_clear_identify(struct client *); void server_update_event(struct client *); /* status.c */ +int status_out_cmp(struct status_out *, struct status_out *); +RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp); +void status_free_jobs(struct status_out_tree *); +void status_update_jobs(struct client *); int status_redraw(struct client *); char *status_replace( struct client *, struct winlink *, const char *, time_t, int); |