Skip to content
Snippets Groups Projects
Commit 976f4b62 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

MAINT-5232: Break out LLCoros::get_id() into its own header file.

We need LLSingleton machinery to be able to reference get_id() without also
depending on all the rest of LLCoros -- since LLCoros isa LLSingleton.
parent f931f6ef
No related branches found
No related tags found
No related merge requests found
...@@ -43,6 +43,7 @@ set(llcommon_SOURCE_FILES ...@@ -43,6 +43,7 @@ set(llcommon_SOURCE_FILES
llcleanup.cpp llcleanup.cpp
llcommon.cpp llcommon.cpp
llcommonutils.cpp llcommonutils.cpp
llcoro_get_id.cpp
llcoros.cpp llcoros.cpp
llcrc.cpp llcrc.cpp
llcriticaldamp.cpp llcriticaldamp.cpp
...@@ -139,6 +140,7 @@ set(llcommon_HEADER_FILES ...@@ -139,6 +140,7 @@ set(llcommon_HEADER_FILES
llcleanup.h llcleanup.h
llcommon.h llcommon.h
llcommonutils.h llcommonutils.h
llcoro_get_id.h
llcoros.h llcoros.h
llcrc.h llcrc.h
llcriticaldamp.h llcriticaldamp.h
......
/**
* @file llcoro_get_id.cpp
* @author Nat Goodspeed
* @date 2016-09-03
* @brief Implementation for llcoro_get_id.
*
* $LicenseInfo:firstyear=2016&license=viewerlgpl$
* Copyright (c) 2016, Linden Research, Inc.
* $/LicenseInfo$
*/
// Precompiled header
#include "linden_common.h"
// associated header
#include "llcoro_get_id.h"
// STL headers
// std headers
// external library headers
// other Linden headers
#include "llcoros.h"
namespace llcoro
{
id get_id()
{
// An instance of Current can convert to LLCoros::CoroData*, which can
// implicitly convert to void*, which is an llcoro::id.
return LLCoros::Current();
}
} // llcoro
/**
* @file llcoro_get_id.h
* @author Nat Goodspeed
* @date 2016-09-03
* @brief Supplement the functionality in llcoro.h.
*
* This is broken out as a separate header file to resolve
* circularity: LLCoros isa LLSingleton, yet LLSingleton machinery
* requires llcoro::get_id().
*
* Be very suspicious of anyone else #including this header.
*
* $LicenseInfo:firstyear=2016&license=viewerlgpl$
* Copyright (c) 2016, Linden Research, Inc.
* $/LicenseInfo$
*/
#if ! defined(LL_LLCORO_GET_ID_H)
#define LL_LLCORO_GET_ID_H
namespace llcoro
{
/// Get an opaque, distinct token for the running coroutine (or main).
typedef void* id;
id get_id();
} // llcoro
#endif /* ! defined(LL_LLCORO_GET_ID_H) */
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include "llcoro_get_id.h" // for friend declaration
// forward-declare helper class // forward-declare helper class
namespace llcoro namespace llcoro
...@@ -146,10 +147,6 @@ class LL_COMMON_API LLCoros: public LLSingleton<LLCoros> ...@@ -146,10 +147,6 @@ class LL_COMMON_API LLCoros: public LLSingleton<LLCoros>
*/ */
std::string getName() const; std::string getName() const;
/// Get an opaque, distinct token for the running coroutine (or main).
typedef void* id;
static id get_id() { return Current(); }
/// for delayed initialization /// for delayed initialization
void setStackSize(S32 stacksize); void setStackSize(S32 stacksize);
...@@ -181,6 +178,7 @@ class LL_COMMON_API LLCoros: public LLSingleton<LLCoros> ...@@ -181,6 +178,7 @@ class LL_COMMON_API LLCoros: public LLSingleton<LLCoros>
LLCoros(); LLCoros();
friend class LLSingleton<LLCoros>; friend class LLSingleton<LLCoros>;
friend class llcoro::Suspending; friend class llcoro::Suspending;
friend llcoro::id llcoro::get_id();
std::string generateDistinctName(const std::string& prefix) const; std::string generateDistinctName(const std::string& prefix) const;
bool cleanup(const LLSD&); bool cleanup(const LLSD&);
struct CoroData; struct CoroData;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment