[libvirt] [PATCH 1/2] Java bindings for domain events

David Lively dlively at virtualiron.com
Wed Nov 19 16:22:31 UTC 2008


On Wed, 2008-11-19 at 10:35 -0500, David Lively wrote:
> The patch already synchronizes operations using virConnect objects with
> each other.  To avoid making illegal EventImpl callbacks from Java for
> the current libvirt, I have to lock every Connect object known to Java
> and hold off creating new connections (via open & friends) around an
> EventImpl callback.  This sounds rather appalling to me, but it's
> starting to sound like the only practical route in the short term
> (unless it turns out we can rely on pthreads in WIN32 ...).

Hmmm ... maybe the less appalling :-) route is practical.  Currently, we
require only the Windows equivalent of a simple pthread mutex.  We just
need to support declaration, initialization, lock, unlock, and
destruction, something like the following (thanks to Tom Hazel for
pointing me to the Windows Mutex stuff):

#if (defined _WIN32 || defined __WIN32__)
#define PTHREAD_MUTEX_T(v) HANDLE v
#define pthread_mutex_init(lk,p) ((*(lk)) = CreateMutex(0, FALSE, 0))
#define pthread_mutex_destroy(lk) CloseHandle(*(lk))
#define pthread_mutex_lock(lk) WaitForSingleObject(*(lk), INFINITE)
#define pthread_mutex_unlock(lk) ReleaseMutex(*(lk))
#define pthread_sigmask(h, s, o) sigprocmask((h), (s), (o))
#endif

I'm not a Windows guy, so maybe I'm missing something.  But this doesn't
seem like a Big Deal ...

Dave





More information about the libvir-list mailing list