diff options
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-x | indra/llcommon/lleventcoro.cpp | 32 | ||||
-rwxr-xr-x | indra/llcommon/lleventcoro.h | 86 | ||||
-rwxr-xr-x | indra/llcommon/llprocess.cpp | 8 | ||||
-rwxr-xr-x | indra/llcommon/tests/lleventcoro_test.cpp | 50 |
4 files changed, 88 insertions, 88 deletions
diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp index 66cc7cada0..031c2cffb0 100755 --- a/indra/llcommon/lleventcoro.cpp +++ b/indra/llcommon/lleventcoro.cpp @@ -45,14 +45,14 @@ namespace { /** - * waitForEventOn() permits a coroutine to temporarily listen on an + * suspendUntilEventOn() permits a coroutine to temporarily listen on an * LLEventPump any number of times. We don't really want to have to ask * the caller to label each such call with a distinct string; the whole - * point of waitForEventOn() is to present a nice sequential interface to + * point of suspendUntilEventOn() is to present a nice sequential interface to * the underlying LLEventPump-with-named-listeners machinery. So we'll use * LLEventPump::inventName() to generate a distinct name for each * temporary listener. On the other hand, because a given coroutine might - * call waitForEventOn() any number of times, we don't really want to + * call suspendUntilEventOn() any number of times, we don't really want to * consume an arbitrary number of generated inventName()s: that namespace, * though large, is nonetheless finite. So we memoize an invented name for * each distinct coroutine instance. @@ -73,7 +73,7 @@ std::string listenerNameForCoro() } /** - * Implement behavior described for postAndWait()'s @a replyPumpNamePath + * Implement behavior described for postEventAndSuspend()'s @a replyPumpNamePath * parameter: * * * If <tt>path.isUndefined()</tt>, do nothing. @@ -145,15 +145,15 @@ void storeToLLSDPath(LLSD& dest, const LLSD& rawPath, const LLSD& value) } // anonymous -void llcoro::yield() +void llcoro::suspend() { // 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"); + // event on "mainloop" gives us a one-frame suspend. + suspendUntilEventOn("mainloop"); } -LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, +LLSD llcoro::postEventAndSuspend(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath) { // declare the future @@ -171,7 +171,7 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request // request event. LLSD modevent(event); storeToLLSDPath(modevent, replyPumpNamePath, replyPump.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + LL_DEBUGS("lleventcoro") << "postEventAndSuspend(): coroutine " << listenerName << " posting to " << requestPump.getPump().getName() << LL_ENDL; @@ -179,7 +179,7 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request // << ": " << modevent << LL_ENDL; requestPump.getPump().post(modevent); } - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + LL_DEBUGS("lleventcoro") << "postEventAndSuspend(): coroutine " << listenerName << " about to wait on LLEventPump " << replyPump.getPump().getName() << LL_ENDL; // trying to dereference ("resolve") the future makes us wait for it @@ -189,7 +189,7 @@ LLSD llcoro::postAndWait(const LLSD& event, const LLEventPumpOrPumpName& request llcoro::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << listenerName + LL_DEBUGS("lleventcoro") << "postEventAndSuspend(): coroutine " << listenerName << " resuming with " << value << LL_ENDL; // returning should disconnect the connection return value; @@ -199,7 +199,7 @@ namespace { /** - * This helper is specifically for the two-pump version of waitForEventOn(). + * This helper is specifically for the two-pump version of suspendUntilEventOn(). * We use a single future object, but we want to listen on two pumps with it. * Since we must still adapt from (the callable constructed by) * boost::dcoroutines::make_callback() (void return) to provide an event @@ -242,7 +242,7 @@ WaitForEventOnHelper<LISTENER> wfeoh(const LISTENER& listener, int discriminator namespace llcoro { -LLEventWithID postAndWait2(const LLSD& event, +LLEventWithID postEventAndSuspend2(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump0, const LLEventPumpOrPumpName& replyPump1, @@ -270,12 +270,12 @@ LLEventWithID postAndWait2(const LLSD& event, replyPump0.getPump().getName()); storeToLLSDPath(modevent, replyPump1NamePath, replyPump1.getPump().getName()); - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + LL_DEBUGS("lleventcoro") << "postEventAndSuspend2(): coroutine " << name << " posting to " << requestPump.getPump().getName() << ": " << modevent << LL_ENDL; requestPump.getPump().post(modevent); } - LL_DEBUGS("lleventcoro") << "postAndWait2(): coroutine " << name + LL_DEBUGS("lleventcoro") << "postEventAndSuspend2(): coroutine " << name << " about to wait on LLEventPumps " << replyPump0.getPump().getName() << ", " << replyPump1.getPump().getName() << LL_ENDL; // trying to dereference ("resolve") the future makes us wait for it @@ -285,7 +285,7 @@ LLEventWithID postAndWait2(const LLSD& event, llcoro::Suspending suspended; value = *future; } // destroy Suspending as soon as we're back - LL_DEBUGS("lleventcoro") << "postAndWait(): coroutine " << name + LL_DEBUGS("lleventcoro") << "postEventAndSuspend(): coroutine " << name << " resuming with (" << value.first << ", " << value.second << ")" << LL_ENDL; // returning should disconnect both connections diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h index 8f3ee38fb4..a09759c9cf 100755 --- a/indra/llcommon/lleventcoro.h +++ b/indra/llcommon/lleventcoro.h @@ -106,33 +106,33 @@ VoidListener<LISTENER> voidlistener(const LISTENER& listener) * runs without suspending for nontrivial time, sprinkle in calls to this * function to avoid stalling the rest of the viewer processing. */ -void yield(); +void suspend(); /** - * Post specified LLSD event on the specified LLEventPump, then wait for a + * Post specified LLSD event on the specified LLEventPump, then suspend for a * response on specified other LLEventPump. This is more than mere * convenience: the difference between this function and the sequence * @code * requestPump.post(myEvent); - * LLSD reply = waitForEventOn(replyPump); + * LLSD reply = suspendUntilEventOn(replyPump); * @endcode * is that the sequence above fails if the reply is posted immediately on * @a replyPump, that is, before <tt>requestPump.post()</tt> returns. In the * sequence above, the running coroutine isn't even listening on @a replyPump - * until <tt>requestPump.post()</tt> returns and @c waitForEventOn() is + * until <tt>requestPump.post()</tt> returns and @c suspendUntilEventOn() is * entered. Therefore, the coroutine completely misses an immediate reply - * event, making it wait indefinitely. + * event, making it suspend indefinitely. * - * By contrast, postAndWait() listens on the @a replyPump @em before posting + * By contrast, postEventAndSuspend() listens on the @a replyPump @em before posting * the specified LLSD event on the specified @a requestPump. * * @param event LLSD data to be posted on @a requestPump * @param requestPump an LLEventPump on which to post @a event. Pass either * the LLEventPump& or its string name. However, if you pass a * default-constructed @c LLEventPumpOrPumpName, we skip the post() call. - * @param replyPump an LLEventPump on which postAndWait() will listen for a + * @param replyPump an LLEventPump on which postEventAndSuspend() will listen for a * reply. Pass either the LLEventPump& or its string name. The calling - * coroutine will wait until that reply arrives. (If you're concerned about a + * coroutine will suspend until that reply arrives. (If you're concerned about a * reply that might not arrive, please see also LLEventTimeout.) * @param replyPumpNamePath specifies the location within @a event in which to * store <tt>replyPump.getName()</tt>. This is a strictly optional convenience @@ -155,21 +155,21 @@ void yield(); * @a replyPumpNamePath specifies the entry in the lowest-level structure in * @a event into which to store <tt>replyPump.getName()</tt>. */ -LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, +LLSD postEventAndSuspend(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump, const LLSD& replyPumpNamePath=LLSD()); /// Wait for the next event on the specified LLEventPump. Pass either the /// LLEventPump& or its string name. inline -LLSD waitForEventOn(const LLEventPumpOrPumpName& pump) +LLSD suspendUntilEventOn(const LLEventPumpOrPumpName& pump) { - // This is now a convenience wrapper for postAndWait(). - return postAndWait(LLSD(), LLEventPumpOrPumpName(), pump); + // This is now a convenience wrapper for postEventAndSuspend(). + return postEventAndSuspend(LLSD(), LLEventPumpOrPumpName(), pump); } } // namespace llcoro -/// return type for two-pump variant of waitForEventOn() +/// return type for two-pump variant of suspendUntilEventOn() typedef std::pair<LLSD, int> LLEventWithID; namespace llcoro @@ -177,7 +177,7 @@ namespace llcoro /** * This function waits for a reply on either of two specified LLEventPumps. - * Otherwise, it closely resembles postAndWait(); please see the documentation + * Otherwise, it closely resembles postAndSuspend(); please see the documentation * for that function for detailed parameter info. * * While we could have implemented the single-pump variant in terms of this @@ -192,19 +192,19 @@ namespace llcoro * the index of the pump on which it arrived (0 or 1). * * @note - * I'd have preferred to overload the name postAndWait() for both signatures. + * I'd have preferred to overload the name postAndSuspend() for both signatures. * But consider the following ambiguous call: * @code - * postAndWait(LLSD(), requestPump, replyPump, "someString"); + * postAndSuspend(LLSD(), requestPump, replyPump, "someString"); * @endcode * "someString" could be converted to either LLSD (@a replyPumpNamePath for * the single-pump function) or LLEventOrPumpName (@a replyPump1 for two-pump * function). * - * It seems less burdensome to write postAndWait2() than to write either + * It seems less burdensome to write postEventAndSuspend2() than to write either * LLSD("someString") or LLEventOrPumpName("someString"). */ -LLEventWithID postAndWait2(const LLSD& event, +LLEventWithID postEventAndSuspend2(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLEventPumpOrPumpName& replyPump0, const LLEventPumpOrPumpName& replyPump1, @@ -216,17 +216,17 @@ LLEventWithID postAndWait2(const LLSD& event, */ inline LLEventWithID -waitForEventOn(const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& pump1) +suspendUntilEventOn(const LLEventPumpOrPumpName& pump0, const LLEventPumpOrPumpName& pump1) { - // This is now a convenience wrapper for postAndWait2(). - return postAndWait2(LLSD(), LLEventPumpOrPumpName(), pump0, pump1); + // This is now a convenience wrapper for postEventAndSuspend2(). + return postEventAndSuspend2(LLSD(), LLEventPumpOrPumpName(), pump0, pump1); } /** - * Helper for the two-pump variant of waitForEventOn(), e.g.: + * Helper for the two-pump variant of suspendUntilEventOn(), e.g.: * * @code - * LLSD reply = errorException(waitForEventOn(replyPump, errorPump), + * LLSD reply = errorException(suspendUntilEventOn(replyPump, errorPump), * "error response from login.cgi"); * @endcode * @@ -286,7 +286,7 @@ LL_COMMON_API LLSD errorLog(const LLEventWithID& result, const std::string& desc * 2. Provide its actual name to the event API in question as the name of the * reply LLEventPump. * 3. Initiate the request to the event API. - * 4. Call your LLEventTempStream's wait() method to wait for the reply. + * 4. Call your LLEventTempStream's suspend() method to suspend for the reply. * 5. Let the LLCoroEventPump go out of scope. */ class LL_COMMON_API LLCoroEventPump @@ -304,15 +304,15 @@ public: /** * Wait for an event on this LLEventPump. */ - LLSD wait() + LLSD suspend() { - return llcoro::waitForEventOn(mPump); + return llcoro::suspendUntilEventOn(mPump); } - LLSD postAndWait(const LLSD& event, const LLEventPumpOrPumpName& requestPump, + LLSD postAndSuspend(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPumpNamePath=LLSD()) { - return llcoro::postAndWait(event, requestPump, mPump, replyPumpNamePath); + return llcoro::postEventAndSuspend(event, requestPump, mPump, replyPumpNamePath); } private: @@ -348,49 +348,49 @@ public: /// request pump 1 LLEventPump& getPump1() { return mPump1; } - /// waitForEventOn(either of our two LLEventPumps) - LLEventWithID wait() + /// suspendUntilEventOn(either of our two LLEventPumps) + LLEventWithID suspend() { - return llcoro::waitForEventOn(mPump0, mPump1); + return llcoro::suspendUntilEventOn(mPump0, mPump1); } - /// errorException(wait()) - LLSD waitWithException() + /// errorException(suspend()) + LLSD suspendWithException() { - return llcoro::errorException(wait(), std::string("Error event on ") + getName1()); + return llcoro::errorException(suspend(), std::string("Error event on ") + getName1()); } - /// errorLog(wait()) - LLSD waitWithLog() + /// errorLog(suspend()) + LLSD suspendWithLog() { - return llcoro::errorLog(wait(), std::string("Error event on ") + getName1()); + return llcoro::errorLog(suspend(), std::string("Error event on ") + getName1()); } - LLEventWithID postAndWait(const LLSD& event, + LLEventWithID postAndSuspend(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return llcoro::postAndWait2(event, requestPump, mPump0, mPump1, + return llcoro::postEventAndSuspend2(event, requestPump, mPump0, mPump1, replyPump0NamePath, replyPump1NamePath); } - LLSD postAndWaitWithException(const LLSD& event, + LLSD postAndSuspendWithException(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return llcoro::errorException(postAndWait(event, requestPump, + return llcoro::errorException(postAndSuspend(event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } - LLSD postAndWaitWithLog(const LLSD& event, + LLSD postAndSuspendWithLog(const LLSD& event, const LLEventPumpOrPumpName& requestPump, const LLSD& replyPump0NamePath=LLSD(), const LLSD& replyPump1NamePath=LLSD()) { - return llcoro::errorLog(postAndWait(event, requestPump, + return llcoro::errorLog(postAndSuspend(event, requestPump, replyPump0NamePath, replyPump1NamePath), std::string("Error event on ") + getName1()); } diff --git a/indra/llcommon/llprocess.cpp b/indra/llcommon/llprocess.cpp index 715df36f39..a8a772b7df 100755 --- a/indra/llcommon/llprocess.cpp +++ b/indra/llcommon/llprocess.cpp @@ -710,7 +710,7 @@ LLProcess::LLProcess(const LLSDOrParams& params): // Tie the lifespan of this child process to the lifespan of our APR // pool: on destruction of the pool, forcibly kill the process. Tell - // APR to try SIGTERM and wait 3 seconds. If that didn't work, use + // APR to try SIGTERM and suspend 3 seconds. If that didn't work, use // SIGKILL. apr_pool_note_subprocess(gAPRPoolp, &mProcess, APR_KILL_AFTER_TIMEOUT); |*==========================================================================*/ @@ -986,9 +986,9 @@ void LLProcess::handle_status(int reason, int status) // wi->rv = apr_proc_wait(wi->child, &wi->rc, &wi->why, APR_NOWAIT); // It's just wrong to call apr_proc_wait() here. The only way APR knows to // call us with APR_OC_REASON_DEATH is that it's already reaped this child - // process, so calling wait() will only produce "huh?" from the OS. We + // process, so calling suspend() will only produce "huh?" from the OS. We // must rely on the status param passed in, which unfortunately comes - // straight from the OS wait() call, which means we have to decode it by + // straight from the OS suspend() call, which means we have to decode it by // hand. mStatus = interpret_status(status); LL_INFOS("LLProcess") << getStatusString() << LL_ENDL; @@ -1231,7 +1231,7 @@ static std::string WindowsErrorString(const std::string& operation) #include <signal.h> #include <fcntl.h> #include <errno.h> -#include <sys/wait.h> +#include <sys/suspend.h> void LLProcess::autokill() { diff --git a/indra/llcommon/tests/lleventcoro_test.cpp b/indra/llcommon/tests/lleventcoro_test.cpp index 00be5035f2..5cced69670 100755 --- a/indra/llcommon/tests/lleventcoro_test.cpp +++ b/indra/llcommon/tests/lleventcoro_test.cpp @@ -129,8 +129,8 @@ typedef coroutine<std::string::iterator(void)> match_coroutine_type; *****************************************************************************/ /// Simulate an event API whose response is immediate: sent on receipt of the /// initial request, rather than after some delay. This is the case that -/// distinguishes postAndWait() from calling post(), then calling -/// waitForEventOn(). +/// distinguishes postEventAndSuspend() from calling post(), then calling +/// suspendUntilEventOn(). class ImmediateAPI { public: @@ -241,13 +241,13 @@ namespace tut // declare the future boost::dcoroutines::future<LLSD> future(self); - // tell the future what to wait for + // tell the future what to suspend for LLTempBoundListener connection( LLEventPumps::instance().obtain("source").listen("coro", voidlistener(boost::dcoroutines::make_callback(future)))); ensure("Not yet", ! future); // attempting to dereference ("resolve") the future causes the calling - // coroutine to wait for it - debug("about to wait"); + // coroutine to suspend for it + debug("about to suspend"); result = *future; ensure("Got it", future); } @@ -269,9 +269,9 @@ namespace tut coro(std::nothrow); // When the coroutine waits for the event pump, it returns here. debug("about to send"); - // Satisfy the wait. + // Satisfy the suspend. LLEventPumps::instance().obtain("source").post("received"); - // Now wait for the coroutine to complete. + // Now suspend for the coroutine to complete. ensure("coroutine complete", ! coro); // ensure the coroutine ran and woke up again with the intended result ensure_equals(result.asString(), "received"); @@ -281,7 +281,7 @@ namespace tut { BEGIN { - result = waitForEventOn("source"); + result = suspendUntilEventOn("source"); } END } @@ -303,7 +303,7 @@ namespace tut { BEGIN { - LLEventWithID pair = waitForEventOn("reply", "error"); + LLEventWithID pair = suspendUntilEventOn("reply", "error"); result = pair.first; which = pair.second; debug(STRINGIZE("result = " << result << ", which = " << which)); @@ -347,7 +347,7 @@ namespace tut { LLCoroEventPump waiter; replyName = waiter.getName(); - result = waiter.wait(); + result = waiter.suspend(); } END } @@ -372,7 +372,7 @@ namespace tut LLCoroEventPumps waiter; replyName = waiter.getName0(); errorName = waiter.getName1(); - LLEventWithID pair(waiter.wait()); + LLEventWithID pair(waiter.suspend()); result = pair.first; which = pair.second; } @@ -414,7 +414,7 @@ namespace tut LLCoroEventPumps waiter; replyName = waiter.getName0(); errorName = waiter.getName1(); - result = waiter.waitWithException(); + result = waiter.suspendWithException(); } END } @@ -441,7 +441,7 @@ namespace tut errorName = waiter.getName1(); try { - result = waiter.waitWithException(); + result = waiter.suspendWithException(); debug("no exception"); } catch (const LLErrorEvent& e) @@ -474,7 +474,7 @@ namespace tut LLCoroEventPumps waiter; replyName = waiter.getName0(); errorName = waiter.getName1(); - result = waiter.waitWithLog(); + result = waiter.suspendWithLog(); } END } @@ -502,7 +502,7 @@ namespace tut WrapLLErrs capture; try { - result = waiter.waitWithLog(); + result = waiter.suspendWithLog(); debug("no exception"); } catch (const WrapLLErrs::FatalException& e) @@ -532,7 +532,7 @@ namespace tut { BEGIN { - result = postAndWait(LLSDMap("value", 17), // request event + result = postEventAndSuspend(LLSDMap("value", 17), // request event immediateAPI.getPump(), // requestPump "reply1", // replyPump "reply"); // request["reply"] = name @@ -554,7 +554,7 @@ namespace tut { BEGIN { - LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18), + LLEventWithID pair = ::postEventAndSuspend2(LLSDMap("value", 18), immediateAPI.getPump(), "reply2", "error2", @@ -582,7 +582,7 @@ namespace tut { BEGIN { - LLEventWithID pair = ::postAndWait2(LLSDMap("value", 18)("fail", LLSD()), + LLEventWithID pair = ::postEventAndSuspend2(LLSDMap("value", 18)("fail", LLSD()), immediateAPI.getPump(), "reply2", "error2", @@ -611,7 +611,7 @@ namespace tut BEGIN { LLCoroEventPump waiter; - result = waiter.postAndWait(LLSDMap("value", 17), + result = waiter.postAndSuspend(LLSDMap("value", 17), immediateAPI.getPump(), "reply"); } END @@ -632,7 +632,7 @@ namespace tut BEGIN { LLCoroEventPumps waiter; - LLEventWithID pair(waiter.postAndWait(LLSDMap("value", 23), + LLEventWithID pair(waiter.postAndSuspend(LLSDMap("value", 23), immediateAPI.getPump(), "reply", "error")); result = pair.first; which = pair.second; @@ -657,7 +657,7 @@ namespace tut { LLCoroEventPumps waiter; LLEventWithID pair( - waiter.postAndWait(LLSDMap("value", 23)("fail", LLSD()), + waiter.postAndSuspend(LLSDMap("value", 23)("fail", LLSD()), immediateAPI.getPump(), "reply", "error")); result = pair.first; which = pair.second; @@ -681,7 +681,7 @@ namespace tut BEGIN { LLCoroEventPumps waiter; - result = waiter.postAndWaitWithException(LLSDMap("value", 8), + result = waiter.postAndSuspendWithException(LLSDMap("value", 8), immediateAPI.getPump(), "reply", "error"); } END @@ -704,7 +704,7 @@ namespace tut LLCoroEventPumps waiter; try { - result = waiter.postAndWaitWithException( + result = waiter.postAndSuspendWithException( LLSDMap("value", 9)("fail", LLSD()), immediateAPI.getPump(), "reply", "error"); debug("no exception"); @@ -734,7 +734,7 @@ namespace tut BEGIN { LLCoroEventPumps waiter; - result = waiter.postAndWaitWithLog(LLSDMap("value", 30), + result = waiter.postAndSuspendWithLog(LLSDMap("value", 30), immediateAPI.getPump(), "reply", "error"); } END @@ -758,7 +758,7 @@ namespace tut WrapLLErrs capture; try { - result = waiter.postAndWaitWithLog( + result = waiter.postAndSuspendWithLog( LLSDMap("value", 31)("fail", LLSD()), immediateAPI.getPump(), "reply", "error"); debug("no exception"); |