]> feistymeow.org Git - feisty_meow.git/commitdiff
adjusted monks's timing
authorFred T. Hamster <fred@feistymeow.org>
Fri, 20 Feb 2026 23:49:56 +0000 (18:49 -0500)
committerFred T. Hamster <fred@feistymeow.org>
Fri, 20 Feb 2026 23:49:56 +0000 (18:49 -0500)
wanted monk to only start after at least the minimum pause period.
points to a need for a start delay optionin the ethread object.

octopi/library/tests_octopus/test_bin_threaded.cpp

index b33cbae936dbed1afa80253d0b30328c4e4f4494..413d0c158b949fbfc5c90808fcdf0574fd37ff05 100644 (file)
@@ -328,7 +328,15 @@ public:
 
   void perform_activity(void *formal(data)) {
     FUNCDEF("perform_activity");
-    if (!__threads_can_run_wild_and_free()) { sleep_time(MIN_MONK_THREAD_PAUSE); return; }
+    if (!__threads_can_run_wild_and_free() || !_hit_first_activation) {
+      _hit_first_activation = true;  // we've seen an activation now for sure.
+      sleep_time(MIN_MONK_THREAD_PAUSE);
+      return; 
+    } else {
+      // still record that we've seen an activation, so we're not gated by the wild & free sentinel for correctness.
+      _hit_first_activation = true;
+    }
+
     // one activation of monk has devastating consequences.  we empty out
     // the data one item at a time until we see no data at all.  after
     // cleaning each item, we ensure that the deadwood is cleaned out.
@@ -359,6 +367,12 @@ LOG(a_sprintf("after this little light cleaning, monk sees %d items held.", bing
     // rude.
     ethread::sleep_time(sleepy_time);
   }
+
+private:
+  bool _hit_first_activation;
+    /* if this is true, then we can start running normally.  we don't fire on the first activation of the thread,
+    because we want monk to only start after its minimum pause period, rather than getting cranked up right away.
+    there is nothing for him to do at program inception anyhow. */
 };
 
 //////////////