[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash server/parser/movie_def_impl.h server/par...
From: |
Bastiaan Jacques |
Subject: |
[Gnash-commit] gnash server/parser/movie_def_impl.h server/par... |
Date: |
Thu, 12 Apr 2007 21:53:12 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Bastiaan Jacques <bjacques> 07/04/12 21:53:12
Modified files:
server/parser : movie_def_impl.h movie_def_impl.cpp
. : ChangeLog
Log message:
Replace pthread usage by boost threads.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2866&r2=1.2867
Patches:
Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- server/parser/movie_def_impl.h 11 Apr 2007 17:54:22 -0000 1.37
+++ server/parser/movie_def_impl.h 12 Apr 2007 21:53:12 -0000 1.38
@@ -35,10 +35,9 @@
#include <map> // for CharacterDictionary
#include <string>
#include <memory> // for auto_ptr
-#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
#include <boost/thread/condition.hpp>
-#include <pthread.h>
//
// Forward declarations
namespace gnash {
@@ -113,8 +112,8 @@
movie_def_impl& _movie_def;
- pthread_mutex_t _mutex;
- pthread_t _thread;
+ mutable boost::mutex _mutex;
+ boost::thread* _thread;
/// Entry point for the actual thread
static void *execute(void* arg);
Index: server/parser/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- server/parser/movie_def_impl.cpp 10 Apr 2007 16:17:54 -0000 1.64
+++ server/parser/movie_def_impl.cpp 12 Apr 2007 21:53:12 -0000 1.65
@@ -37,14 +37,12 @@
#include "GnashException.h" // for parser exception
#include "execute_tag.h"
#include "sound_definition.h" // for sound_sample
+#include <boost/bind.hpp>
#include <memory>
#include <string>
#include <unistd.h>
-#ifdef HAVE_PTHREADS
-#include <pthread.h>
-#endif
// Increment this when the cache data format changes.
#define CACHE_FILE_VERSION 4
@@ -74,47 +72,32 @@
MovieLoader::MovieLoader(movie_def_impl& md)
:
_movie_def(md)
-#ifndef WIN32
- ,_thread(0)
-#endif
+ ,_thread(NULL)
{
-#ifdef LOAD_MOVIES_IN_A_SEPARATE_THREAD
- pthread_mutex_init(&_mutex, NULL);
-#endif
-
-#ifdef WIN32
- _thread.p = 0;
-#endif
}
MovieLoader::~MovieLoader()
{
-#ifdef LOAD_MOVIES_IN_A_SEPARATE_THREAD
- if ( pthread_mutex_destroy(&_mutex) != 0 )
- {
- log_error("Error destroying MovieLoader mutex");
- }
-#endif
}
bool
MovieLoader::started() const
{
-#ifdef WIN32
- return _thread.p != NULL;
-#else
- return _thread != 0;
-#endif
+ boost::mutex::scoped_lock lock(_mutex);
+
+ return _thread != NULL;
}
bool
MovieLoader::isSelfThread() const
{
-#ifdef WIN32
- return _thread.p == pthread_self().p;
-#else
- return pthread_self() == _thread;
-#endif
+ boost::mutex::scoped_lock lock(_mutex);
+
+ if (!_thread) {
+ return false;
+ }
+ boost::thread this_thread;
+ return this_thread == *_thread;
}
void*
@@ -123,12 +106,6 @@
movie_def_impl* md = static_cast<movie_def_impl*>(arg);
md->read_all_swf();
- // maybe this frees all resources and that's bad !
- //pthread_exit(NULL);
-
- /* Better to cancel yourself methinks: 'man 3p pthread_cancel' */
- pthread_cancel(pthread_self());
- pthread_testcancel();
return NULL;
}
@@ -139,12 +116,13 @@
// don't start MovieLoader thread !
assert(0);
#endif
- if ( pthread_create(&_thread, NULL, execute, &_movie_def) )
- {
- return false;
- }
+ // We have two sanity checks, started() and isSelfThread() which rely
+ // on boost::thread() returning before they are executed. Therefore,
+ // we must employ locking.
+ // Those tests do seem a bit redundant, though...
+ boost::mutex::scoped_lock lock(_mutex);
- // should set some mutexes ?
+ _thread = new boost::thread(boost::bind(execute, &_movie_def));
return true;
}
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2866
retrieving revision 1.2867
diff -u -b -r1.2866 -r1.2867
--- ChangeLog 12 Apr 2007 16:31:41 -0000 1.2866
+++ ChangeLog 12 Apr 2007 21:53:12 -0000 1.2867
@@ -1,3 +1,8 @@
+2007-04-12 Bastiaan Jacques <address@hidden>
+
+ * server/parser/movie_def_impl.{cpp,h}: Replace pthread usage
+ by boost threads.
+
2007-04-12 Sandro Santilli <address@hidden>
* server/asobj/string.cpp (fromCharCode): revert bastiaan change
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash server/parser/movie_def_impl.h server/par...,
Bastiaan Jacques <=