diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2015-07-04 19:58:03 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2015-07-04 19:58:03 -0400 |
commit | 1d2514956f15f780aaead9bc123c1353a5b7fd20 (patch) | |
tree | 113814dce7ce62aa696d96f811e24cc0e6d7f04c | |
parent | d34476359e59a1902b1498fbed94daca3d20bff1 (diff) |
MAINT-5357: Add llcoro::yield() function to yield for one frame.
-rwxr-xr-x | indra/llcommon/lleventcoro.cpp | 8 | ||||
-rwxr-xr-x | indra/llcommon/lleventcoro.h | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index b7e7edec5a..ad02e139b8 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -145,6 +145,14 @@ void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) } // anonymous +void llcoro::yield() +{ + // By viewer convention, we post an event on the "mainloop" LLEventPump + // each iteration of the main event-handling loop. So waiting for a single + // event on "mainloop" gives us a one-frame yield. + waitForEventOn("mainloop"); +} + LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) { diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index f1c5dc2fde..e2ce4bb193 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -102,6 +102,13 @@ VoidListener<LISTENER> voidlistener(const LISTENER& listener) } /** + * Yield control from a coroutine for one "mainloop" tick. If your coroutine + * runs without suspending for nontrivial time, sprinkle in calls to this + * function to avoid stalling the rest of the viewer processing. + */ +void yield(); + +/** * Post specified LLSD event on the specified LLEventPump, then wait for a * response on specified other LLEventPump. This is more than mere * convenience: the difference between this function and the sequence |