Mercurial > hg > vampy
view Mutex.h @ 24:7d28bed0864e
* Rearrange Python plugin construction.
Formerly, the PyPluginAdapter has retained a single plugin instance pointer
for each plugin found, and its createPlugin method has simply returned a new
PyPlugin object wrapping the same instance pointer. This has a couple of
negative consequences:
- Because construction of the actual Python instance occurred before the
wrapper was constructed, it was not possible to pass arguments (i.e.
the sample rate) from the wrapper constructor to the Python plugin
instance constructor -- they had to be passed later, to initialise,
disadvantaging those plugins that would like to use the sample rate
for parameter & step/block size calculations etc
- Because there was only a single Python plugin instance, it was not
possible to run more than one instance at once with any isolation
This rework instead stores the Python class pointer (rather than instance
pointer) in the PyPluginAdapter, and each PyPlugin wrapper instance creates
its own Python plugin instance. What could possibly go wrong?
author | cannam |
---|---|
date | Mon, 17 Aug 2009 15:22:06 +0000 |
parents | 134313c59d82 |
children |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Basic cross-platform mutex abstraction class. This file copyright 2007 Chris Cannam. */ #ifndef _MUTEX_H_ #define _MUTEX_H_ #ifdef _WIN32 #include <windows.h> #else #include <pthread.h> #endif class Mutex { public: Mutex(); ~Mutex(); void lock(); void unlock(); bool trylock(); private: #ifdef _WIN32 HANDLE m_mutex; #ifndef NO_THREAD_CHECKS DWORD m_lockedBy; #endif #else pthread_mutex_t m_mutex; #ifndef NO_THREAD_CHECKS pthread_t m_lockedBy; bool m_locked; #endif #endif }; class MutexLocker { public: MutexLocker(Mutex *); ~MutexLocker(); private: Mutex *m_mutex; }; #endif