[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-
From: |
Bastiaan Jacques |
Subject: |
[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-2173-g2fa246e |
Date: |
Sat, 24 Jan 2015 16:46:08 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".
The branch, master has been updated
via 2fa246e28fc0c8445c97b044c5c6a6677860cda2 (commit)
from 9957d022bfa63e87a2d5dd9719c2d0c071d977d6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=2fa246e28fc0c8445c97b044c5c6a6677860cda2
commit 2fa246e28fc0c8445c97b044c5c6a6677860cda2
Author: Bastiaan Jacques <address@hidden>
Date: Sat Jan 24 13:46:59 2015 +0100
Savannah #42712. Go back to using std::thread directly.
std::future and std::async have not (yet) been implemented in
libstdc++ for armel and similar platforms. See GCC bug #64735.
diff --git a/libcore/LoadVariablesThread.cpp b/libcore/LoadVariablesThread.cpp
index 2b1ef3a..eb964fe 100644
--- a/libcore/LoadVariablesThread.cpp
+++ b/libcore/LoadVariablesThread.cpp
@@ -32,10 +32,9 @@ namespace gnash {
// static
LoadVariablesThread::ValuesMap
-LoadVariablesThread::completeLoad(IOChannel* varstream,
- std::atomic<bool>& canceled)
+LoadVariablesThread::completeLoad(std::unique_ptr<IOChannel> stream,
+ const std::atomic<int8_t>& status)
{
- std::unique_ptr<IOChannel> stream(varstream);
#ifdef DEBUG_LOAD_VARIABLES
log_debug("completeLoad called");
#endif
@@ -100,7 +99,7 @@ LoadVariablesThread::completeLoad(IOChannel* varstream,
break;
}
- if ( canceled.load() ) {
+ if ( static_cast<Status>(status.load()) == Status::CANCEL_REQUESTED ) {
log_debug("Cancelling LoadVariables download thread...");
stream.reset();
return parseResult;
@@ -125,21 +124,18 @@ LoadVariablesThread::completeLoad(IOChannel* varstream,
}
//dispatchLoadEvent();
- canceled = true;
return parseResult;
}
LoadVariablesThread::LoadVariablesThread(const StreamProvider& sp,
const URL& url, const std::string& postdata)
- : _canceled(false)
{
startThread(sp.getStream(url, postdata));
}
LoadVariablesThread::LoadVariablesThread(const StreamProvider& sp,
const URL& url)
- : _canceled(false)
{
startThread(sp.getStream(url));
}
@@ -151,17 +147,18 @@
LoadVariablesThread::startThread(std::unique_ptr<IOChannel> stream)
throw NetworkException();
}
- // Passing IOStream* rather than unique_ptr serves to appease GCC 4.6,
- // which insists the arguments are CopyConstructible rather than Movable.
- _vals = std::async(std::launch::async, completeLoad, stream.release(),
- std::ref(_canceled));
+ _thread = std::thread(
+ [&] (IOChannel* varstream) {
+ _vals = completeLoad(std::unique_ptr<IOChannel>(varstream), _status);
+ _status = static_cast<int8_t>(Status::FINISHED);
+ }, stream.release());
}
LoadVariablesThread::~LoadVariablesThread()
{
- if ( _vals.valid() ) {
- _canceled = true;
- _vals.wait();
+ if (_thread.joinable()) {
+ _status = static_cast<int8_t>(Status::CANCEL_REQUESTED);
+ _thread.join();
}
}
diff --git a/libcore/LoadVariablesThread.h b/libcore/LoadVariablesThread.h
index 0be3985..341a5f4 100644
--- a/libcore/LoadVariablesThread.h
+++ b/libcore/LoadVariablesThread.h
@@ -23,9 +23,10 @@
#include <string>
#include <map>
-#include <future>
#include <atomic>
-
+#include <cassert>
+#include <memory>
+#include <thread>
namespace gnash {
class StreamProvider;
@@ -49,6 +50,8 @@ class LoadVariablesThread
public:
typedef std::map<std::string, std::string> ValuesMap;
+ enum class Status : std::int8_t { STARTED = 0, FINISHED,
CANCEL_REQUESTED };
+
/// Construct a LoadVariablesThread opening a stream for the given URL
//
/// Throws a NetworkException if unable.
@@ -79,12 +82,13 @@ public:
/// Return the name,value map parsed out of the loaded stream
ValuesMap getValues()
{
- return _vals.get();
+ assert(completed());
+ return _vals;
}
bool completed()
{
- return _canceled;
+ return static_cast<Status>(_status.load()) == Status::FINISHED;
}
private:
@@ -99,15 +103,13 @@ private:
//
/// This function should be run by a separate thread.
///
- static ValuesMap completeLoad(IOChannel* stream,
- std::atomic<bool>& canceled);
+ static ValuesMap completeLoad(std::unique_ptr<IOChannel> stream,
+ const std::atomic<int8_t>& status);
- std::future<ValuesMap> _vals;
+ ValuesMap _vals;
- /// Indicates either whether cancellation was requested, or whether the
- /// thread has finished executing code, from the perspective of the
- /// variables loading thread thread and the main thread respectively.
- std::atomic<bool> _canceled;
+ std::thread _thread;
+ std::atomic<int8_t> _status; // enum class Status; int for
compatibility.
};
} // namespace gnash
-----------------------------------------------------------------------
Summary of changes:
libcore/LoadVariablesThread.cpp | 25 +++++++++++--------------
libcore/LoadVariablesThread.h | 24 +++++++++++++-----------
2 files changed, 24 insertions(+), 25 deletions(-)
hooks/post-receive
--
Gnash
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-2173-g2fa246e,
Bastiaan Jacques <=