llcoproceduremanager.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * @file llcoproceduremanager.h
  3. * @author Rider Linden
  4. * @brief Singleton class for managing asset uploads to the sim.
  5. *
  6. * $LicenseInfo:firstyear=2015&license=viewergpl$
  7. *
  8. * Copyright (c) 2015, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #ifndef LL_COPROCEDURE_MANAGER_H
  34. #define LL_COPROCEDURE_MANAGER_H
  35. #include <map>
  36. #include "llcorehttputil.h"
  37. #include "llsingleton.h"
  38. class LLCoprocedurePool;
  39. class LLCoprocedureManager final : public LLSingleton<LLCoprocedureManager>
  40. {
  41. friend class LLSingleton<LLCoprocedureManager>;
  42. protected:
  43. LOG_CLASS(LLCoprocedureManager);
  44. public:
  45. typedef boost::function<U32(const std::string&)> setting_query_t;
  46. typedef boost::function<void(const std::string&, U32)> setting_upd_t;
  47. typedef boost::function<void(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t&,
  48. const LLUUID&)> coprocedure_t;
  49. LLCoprocedureManager() = default;
  50. // Places the coprocedure on the queue for processing.
  51. //
  52. // @param name Is used for debugging and should identify this coroutine.
  53. // @param proc Is a bound function to be executed
  54. //
  55. // @return This method returns a UUID that can be used later to cancel
  56. // execution.
  57. LLUUID enqueueCoprocedure(const std::string& pool, const std::string& name,
  58. coprocedure_t proc);
  59. void setPropertyMethods(setting_query_t queryfn, setting_upd_t updatefn);
  60. // Requests an exit for all the coprocedure manager coroutines.
  61. void cleanup();
  62. // Returns the number of coprocedures in the queue awaiting processing.
  63. U32 countPending() const;
  64. U32 countPending(const std::string& pool) const;
  65. // Returns the number of coprocedures actively being processed.
  66. U32 countActive() const;
  67. U32 countActive(const std::string& pool) const;
  68. // Returns the total number of coprocedures either queued or in active
  69. // processing.
  70. U32 count() const;
  71. U32 count(const std::string& pool) const;
  72. typedef std::shared_ptr<LLCoprocedurePool> pool_ptr_t;
  73. pool_ptr_t initializePool(const std::string& pool_name);
  74. private:
  75. typedef std::map<std::string, pool_ptr_t> pool_map_t;
  76. pool_map_t mPoolMap;
  77. setting_query_t mPropertyQueryFn;
  78. setting_upd_t mPropertyDefineFn;
  79. };
  80. #endif