diff options
| author | Nat Goodspeed <nat@lindenlab.com> | 2019-12-12 10:35:47 -0500 | 
|---|---|---|
| committer | Nat Goodspeed <nat@lindenlab.com> | 2020-03-25 15:28:17 -0400 | 
| commit | 6586918df0039f60c1c02c134a6a0e0762997d56 (patch) | |
| tree | 3cfb1be58b46427e113aa62e61a55dfca58e5659 | |
| parent | dd98717caa712c17ef6a8f187754670b614ab253 (diff) | |
DRTVWR-494: Remove LLMainThreadTask::dispatch(LockStatic&, ...)
Monty's code review reveals that conflating dispatch() with [un]lock
functionality is inconsistent and unnecessary.
| -rw-r--r-- | indra/llcommon/llmainthreadtask.h | 35 | 
1 files changed, 2 insertions, 33 deletions
| diff --git a/indra/llcommon/llmainthreadtask.h b/indra/llcommon/llmainthreadtask.h index 2e0583d104..d509b687c0 100644 --- a/indra/llcommon/llmainthreadtask.h +++ b/indra/llcommon/llmainthreadtask.h @@ -15,11 +15,9 @@  #include "lleventtimer.h"  #include "llthread.h" -#include "lockstatic.h"  #include "llmake.h"  #include <future>  #include <type_traits>              // std::result_of -#include <boost/signals2/dummy_mutex.hpp>  /**   * LLMainThreadTask provides a way to perform some task specifically on the @@ -42,33 +40,17 @@   * will fulfill a future with its result. Meanwhile the requesting thread   * blocks on that future. As soon as it is set, the requesting thread wakes up   * with the task result. - * - * Under some circumstances it's necessary for the calling thread to hold a - * lock until the task has been scheduled -- yet important to release the lock - * while waiting for the result. If you pass a LockStatic<T> to dispatch(), - * a secondary thread will unlock it before blocking on the future. (The main - * thread simply holds the lock for the duration of the task.)   */  class LLMainThreadTask  {  private:      // Don't instantiate this class -- use dispatch() instead.      LLMainThreadTask() {} -    // If our caller doesn't explicitly pass a LockStatic<something>, make a -    // fake one. -    struct Static -    { -        boost::signals2::dummy_mutex mMutex; -    }; -    typedef llthread::LockStatic<Static> LockStatic;  public:      /// dispatch() is the only way to invoke this functionality. -    /// If you call it with a LockStatic<something>, dispatch() unlocks it -    /// before blocking for the result. -    template <typename Static, typename CALLABLE> -    static auto dispatch(llthread::LockStatic<Static>& lk, CALLABLE&& callable) -        -> decltype(callable()) +    template <typename CALLABLE> +    static auto dispatch(CALLABLE&& callable) -> decltype(callable())      {          if (on_main_thread())          { @@ -82,25 +64,12 @@ public:              // Once we enable C++17, we can use Class Template Argument              // Deduction. Until then, use llmake_heap().              auto* task = llmake_heap<Task>(std::forward<CALLABLE>(callable)); -            // The moment we construct a new LLEventTimer subclass object, its -            // tick() method might get called. However, its tick() method -            // might depend on something locked by the passed LockStatic. -            // Unlock it so tick() can proceed. -            lk.unlock();              auto future = task->mTask.get_future();              // Now simply block on the future.              return future.get();          }      } -    /// You can call dispatch() without a LockStatic<something>. -    template <typename CALLABLE> -    static auto dispatch(CALLABLE&& callable) -> decltype(callable()) -    { -        LockStatic lk; -        return dispatch(lk, std::forward<CALLABLE>(callable)); -    } -  private:      template <typename CALLABLE>      struct Task: public LLEventTimer | 
