]> git.neil.brown.name Git - edlib.git/commitdiff
Limit the consistency checks run in each loop
authorNeilBrown <neil@brown.name>
Fri, 15 Sep 2023 03:11:02 +0000 (13:11 +1000)
committerNeilBrown <neil@brown.name>
Fri, 15 Sep 2023 03:38:14 +0000 (13:38 +1000)
Limit the number of consistency check run for a single user command to
about 60.
Maybe this could use times_up???

Signed-off-by: NeilBrown <neil@brown.name>
DOC/TODO.md
core-mark.c
core-pane.c
core-pane.h
doc-text.c

index 9e532bfacbd8c6aee2b51cba8a18413304b4a4b0..59f408a337649a6a2630541207e0038b4608fa13 100644 (file)
@@ -29,6 +29,8 @@ the file.
 - [ ] selection-menu sub-menu for UPPER lower Caps ??
 - [ ] selection-menu item for text-fill
 - [ ] selection-menu item for spell-check ??
+- [ ] notmuch - capture errors about multiple Subject lines and
+      display them better.
 
 ### Small
 
@@ -82,6 +84,8 @@ Requirements for a v1.0 release
 Core features
 -------------
 
+- [ ] universal times_up tests might cause Close_mark or similar
+      not to be called.  How can we avoid that?
 - [ ] If a pane wants to block mouse events from parents, as lib-view
       does, it shouldn't need to catch all the combinations, or it
       should be much easier
@@ -128,7 +132,7 @@ Core features
       I need a simple way to intercept any change.
 - [X] switch-buffer in pop-up window - shouldn't kill the popup (does it?)
 - [X] explicitly guard against infinite loops in consistency checks
-- [ ] skip consistency checks after several with no stop for input.
+- [X] skip consistency checks after several with no stop for input.
 - [ ] unwanted docs too easily appear high in recent-list - *Output*
 - [ ] design a way for a keystroke to interrupt a long-running function.
 - [ ] extend Draw:measure protocol to allow constant-width-fonts to
index a5f7dd96a77c32ed8a2ec565a7540eaa70c4f827..b24d52b7d69ea10cc340cef4981edec5f05903d5 100644 (file)
@@ -1205,6 +1205,9 @@ void doc_check_consistent(struct doc *d safe)
        int max = 1000;
        static bool warned = False;
 
+       if (pane_no_consistency(safe_cast container_of(d, struct pane, doc)))
+               return;
+
        hlist_for_each_entry(m, &d->marks, all) {
                ASSERT(m->seq >= seq);
                ASSERT(&m->owner->doc == d);
index b772bc9ea366a9f006997bb121f27f1517e2a63f..5a872df8d7b43e0f58686a48e96199c793b9e3ee 100644 (file)
@@ -1239,3 +1239,17 @@ void pane_set_time(struct pane *p safe)
        if (p->timestamp <= 1)
                p->timestamp = 2;
 }
+
+DEF_CB(clear_consistency)
+{
+       ci->focus->consistency_checks = 0;
+       return 1;
+}
+
+bool pane_no_consistency(struct pane *p safe)
+{
+       p->consistency_checks += 1;
+       if (p->consistency_checks == 50)
+               call_comm("event:on-idle", p, &clear_consistency, 2);
+       return p->consistency_checks > 60;
+}
index 2d819e1079982f70e1aa813bfcbdf4f1bfaf64a1..907cc1b1fd4f7059e09d745230e3972d874ea568 100644 (file)
@@ -11,6 +11,7 @@ struct pane {
 
        short                   damaged;
        short                   alloc_size;
+       short                   consistency_checks;
 
        int                     marks;
        int                     refs;
@@ -52,6 +53,7 @@ struct pane {
        };
 };
 
+bool pane_no_consistency(struct pane *p safe);
 bool pane_too_long(struct pane *p safe, unsigned int msec);
 void pane_set_time(struct pane *p safe);
 static inline void pane_end_time(struct pane *p safe)
index b8d446168a9b75464a27e7464786c9a2e2f7c44d..e99eddddd276e30cb688364b3cccdee18217e777 100644 (file)
@@ -2086,6 +2086,9 @@ static void text_check_consistent(struct text *t safe)
        struct doc *d = &t->doc;
        int loops = 10000;
 
+       if (pane_no_consistency(safe_cast container_of(d, struct pane, doc)))
+               return;
+
        list_for_each_entry(c, &t->text, lst) {
                check_allocated(t, c->txt, c->end);
                if (c->start >= c->end)