-5

Constrained by a main loop outside of my control (eg: UI event loop, game loop, etc...), I have a slow (relative to the main loop's expectations) algorithm involving a loop. Thus, I have to restructure the loop to be ___ (what is this term?) so that it can run partially each iteration (not 1:1) of the main loop (ie: splitting the loop into separate loop setup, check, logic, save, & teardown procedures). I'm aware that threading solves this issue w/o the need to refactor, and I'm not asking for the solution to needing to do this refactoring (even if it is effectively emulating entirely in user mode the logic supporting interrupts & context switching in a CPU), just the term for it.

Words I've come up with but already have other meanings in programming:

re-entrant, serialized, unrolled

If this term already exists, my google-fu has been unable to identify it.

  • 2
    You'd be better off stating your specific requirements and asking for a solution. We're not a dictionary. Perhaps you're looking for "parallelization" or "concurrency"? Maybe "asynchronous"? – Robert Harvey Nov 28 '17 at 4:18
  • I don't need help with the refactoring itself or the way to eliminate it via threading (i can't feasibly do threading due to embedded hardware limitations), just a term to effectively communicate it quickly. "concurrent loop" does seem to be what i am looking for once i parse out all the results actually discussing parallel loops. If you post that as an answer I'll mark it, and thank you. – Peter K Nov 28 '17 at 4:37
  • 1
    There isn't enough information in your question to match it to a term. Perhaps that's why your Google searches aren't working. – Robert Harvey Nov 28 '17 at 14:37
  • Maybe you are referring to Big O Notation? – Greg Burghardt Nov 28 '17 at 17:43
  • Not quite. the Big O would be the same, it's just a difference of running all at once or starting & stopping based on it needing to not take up too much CPU – Peter K Nov 28 '17 at 20:50
1

The full concept I was looking for was similar to generators but less restricted/specific, and I didn't mention that since I felt use of the term "generator" would distract from the fundamental inquiry.

Generators are also known as semi-co-routines. Co-routines are what I was ultimately looking for, and they are used to implement co-operative/non-preemptive multi-tasking, which is the concept I was failing to accurately describe in my question.

0

The word you are looking for is "an incremental update". You are changing from a single loop making many mutations, to many calls, each making one mutation. It is no longer called a "loop," as it is not looping.

  • It is still looping since I might be able to fit, say, 5 iterations, before I have to yield back to the main loop without affecting responsiveness. Also, I don't think "incremental" applies to a sort or search algorithm where the result is not used until it is entirely complete, but it would be appropriate for streaming algorithms (eg: a pathfinding loop that calculates as much of its future path as it can before yielding). Until Robert Harvey posts "concurrent loop" as a real answer, I'll mark this as the answer, since it is accurate for part of the problem domain. – Peter K Nov 28 '17 at 21:06
  • "Concurrent" usually refers to two or more activities happening at the same time. When you implement an iterator, that calculates results on demand, it is a similar type of activity. – Frank Hileman Dec 5 '17 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.