summaryrefslogtreecommitdiff
path: root/indra/llcommon/llcoros.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2009-06-04 16:01:40 +0000
committerNat Goodspeed <nat@lindenlab.com>2009-06-04 16:01:40 +0000
commit820d4a20d1b9c9a3e562b925ba59a6addcffa558 (patch)
tree5eb6e1cfb95d408cfabfafd6cd5ddb1e6d4a507e /indra/llcommon/llcoros.cpp
parenta3d54c48c6366a8a38e20a5aacd90bbc39018512 (diff)
DEV-32777: Use a canonical boost::coroutines::coroutine signature, relying on
boost::bind() to pass any other coroutine arguments. This allows us to remove the LLCoroBase and LLCoro constructs, directly storing a coroutine object in our ptr_map. It also allows us to remove the multiple launch() overloads for multiple arguments. Finally, it lets us move most launch() functionality into a non-template method.
Diffstat (limited to 'indra/llcommon/llcoros.cpp')
-rw-r--r--indra/llcommon/llcoros.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp
index 6fa6ae8f1a..5d23e1d284 100644
--- a/indra/llcommon/llcoros.cpp
+++ b/indra/llcommon/llcoros.cpp
@@ -54,6 +54,15 @@ bool LLCoros::cleanup(const LLSD&)
return false;
}
+std::string LLCoros::launchImpl(const std::string& prefix, coro* newCoro)
+{
+ std::string name(generateDistinctName(prefix));
+ mCoros.insert(name, newCoro);
+ /* Run the coroutine until its first wait, then return here */
+ (*newCoro)(std::nothrow);
+ return name;
+}
+
std::string LLCoros::generateDistinctName(const std::string& prefix) const
{
// Allowing empty name would make getName()'s not-found return ambiguous.
@@ -86,8 +95,8 @@ bool LLCoros::kill(const std::string& name)
return false;
}
// Because this is a boost::ptr_map, erasing the map entry also destroys
- // the referenced heap object, in this case an LLCoro. That will destroy
- // the contained boost::coroutine object, which will terminate the coroutine.
+ // the referenced heap object, in this case the boost::coroutine object,
+ // which will terminate the coroutine.
mCoros.erase(found);
return true;
}
@@ -98,7 +107,9 @@ std::string LLCoros::getNameByID(const void* self_id) const
// passed to us comes.
for (CoroMap::const_iterator mi(mCoros.begin()), mend(mCoros.end()); mi != mend; ++mi)
{
- if (mi->second->owns_self_id(self_id))
+ namespace coro_private = boost::coroutines::detail;
+ if (static_cast<void*>(coro_private::coroutine_accessor::get_impl(const_cast<coro&>(*mi->second)).get())
+ == self_id)
{
return mi->first;
}