codlab / android_process_mutex

0 stars 1 forks source link

Android Mutex across Processus

A simple mutex based system for Android to share mutex locking system across threads and even processus.

How it works ?

Since Android does not provide standard Shared Memory APIs, the library is based on https://github.com/pelya/android-shmem which provide everything you need to add support for such a feature.

pthread + mutex are used inside the library

How to use ?

compile 'eu.codlab:android_process_mutex:0.9.3'

At first, create an instance of the object, prefereably in the Application instance Globally initialize :

Mutex.initAll();

Then simply :

Mutex my_mutex = new Mutex();
my_mutex.init();

...

my_mutex.lock();
//enter the critical section

... stuff in critical section ...

//quit the critical section
my_mutex.unlock();

...

my_mutex.release();

Example ? those lines in Threads, AsyncTask, AbstractThreadedSyncAdapter, ...

Compatibility & limitation

Compatible with every Android version, every architecture.

As state in the TODOs, the library lacks of some feature (!!). Any issue, comments? Feel free to comment, share, pull request

TODOs