new visitor implementation now ready for use

This commit is contained in:
Fischlurch 2008-01-05 19:42:43 +01:00
parent 8fe1a901ba
commit 9e6459cc47
2 changed files with 22 additions and 7 deletions

View file

@ -28,6 +28,7 @@
#include "common/error.hpp"
#include "common/util.hpp"
#include "common/singleton.hpp"
#include "common/multithread.hpp"
#include <vector>
@ -57,6 +58,15 @@ namespace cinelerra
size_t tagID; ///< tag value
static size_t lastRegisteredID;
private:
static void
generateID (size_t& id)
{
Thread::Lock<Tag> guard SIDEEFFECT;
if (!id)
id = ++lastRegisteredID;
}
public:
Tag() : tagID(0) { }
operator size_t() const { return tagID; }
@ -66,10 +76,8 @@ namespace cinelerra
static Tag&
get (TOOLImpl* const concreteTool=0)
{
TODO ("race condition");
Tag& t = TagTypeRegistry<TOOL,TOOLImpl>::tag;
if (!t)
t.tagID = ++lastRegisteredID;
if (!t) generateID (t.tagID);
return t;
}
@ -127,6 +135,14 @@ namespace cinelerra
std::vector<Trampoline> table_;
void
accomodate (size_t index)
{
Thread::Lock<Dispatcher> guard SIDEEFFECT;
if (index > table_.size())
table_.resize (index); // performance bottleneck?? TODO: measure the real impact!
}
inline bool
is_known (size_t id)
{
@ -136,9 +152,10 @@ namespace cinelerra
inline void
storePtr (size_t id, Trampoline func)
{
TODO ("error- and concurrency handling");
REQUIRE (func);
REQUIRE (0 < id);
if (id>table_.size())
table_.resize (id); // performance bottleneck?? TODO: measure the real impact!
accomodate (id);
table_[id-1] = func;
}

View file

@ -27,7 +27,6 @@
#include "common/multithread.hpp"
#include "common/util.hpp"
//#include <boost/lambda/lambda.hpp>
#include <boost/function.hpp>
#include <boost/format.hpp>
@ -37,7 +36,6 @@ using std::tr1::static_pointer_cast;
using boost::function;
using boost::format;
using boost::bind;
//using boost::lambda::_1;
using util::for_each;
using cinelerra::Singleton;