blackberry / WebWorks-Community-APIs

Community owned repository containing JavaScript Extensions for BlackBerry WebWorks
Apache License 2.0
141 stars 205 forks source link

Plugin Template: mutex not initialized correctly #407

Closed dietmar closed 9 years ago

dietmar commented 9 years ago

I have written a Webworks plugin based off your excellent plugin template, in the course of that I found a bug: template_ndk.hpp defines two private member variables cond and mutex (see here).

In the corresponding constructor in template_ndk.cpp, these two are supposed to get initialized, but they aren't. Instead, new variables, which are local to the constructor, are declared (see here), which for me meant that the mutex was never correctly initialized, my thread synchronization acted weirdly and my app froze.

Long story short: in template_ndk.cpp, this:

        pthread_cond_t cond  = PTHREAD_COND_INITIALIZER;
        pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

should become this:

        cond  = PTHREAD_COND_INITIALIZER;
        mutex = PTHREAD_MUTEX_INITIALIZER;

Thanks for this (otherwise ;-) ) great template.

timwindsor commented 9 years ago

Yes I see that. We seem to have missed that in our tweaks to the template. Thanks for pointing it out.