Make events per-parser

This makes the following changes:

1. Events in background threads are executed in those threads, instead of
being silently dropped

2. Blocked events are now per-parser instead of global

3. Events are posted in builtin_set instead of within the environment stack

The last one means that we no longer support event handlers for implicit
sets like (example) argv. Instead only the `set` builtin (and also `cd`)
post variable-change events.

Events from universal variable changes are still not fully rationalized.
This commit is contained in:
ridiculousfish
2019-06-03 02:31:13 -07:00
parent 890c1188ab
commit ff55249447
18 changed files with 115 additions and 72 deletions

View File

@@ -45,6 +45,7 @@
#include "input_common.h"
#include "maybe.h"
#include "output.h"
#include "parser.h"
#include "proc.h"
#include "reader.h"
#include "screen.h"
@@ -211,7 +212,9 @@ static void universal_callback(env_stack_t *stack, const callback_data_t &cb) {
env_dispatch_var_change(cb.key, *stack);
stack->mark_changed_exported();
event_fire(event_t::variable(cb.key, {L"VARIABLE", op, cb.key}));
// TODO: eliminate this principal_parser. Need to rationalize how multiple threads work here.
event_fire(parser_t::principal_parser(), event_t::variable(cb.key, {L"VARIABLE", op, cb.key}));
}
void env_universal_callbacks(env_stack_t *stack, const callback_data_list_t &callbacks) {