WaitForSingleObject and WaitForMultipleObjects equivalent in Linux?

Stick to pthread_cond_timedwait and use clock_gettime. For example: struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); ts.tv_sec += 10; // ten seconds while (!some_condition && ret == 0) ret = pthread_cond_timedwait(&cond, &mutex, &ts); Wrap it in a function if you wish. UPDATE: complementing the answer based on our comments. POSIX doesn’t have a single API to wait for … Read more

How do I take ownership of an abandoned boost::interprocess::interprocess_mutex?

Unfortunately, this isn’t supported by the boost::interprocess API as-is. There are a few ways you could implement it however: If you are on a POSIX platform with support for pthread_mutexattr_setrobust_np, edit boost/interprocess/sync/posix/thread_helpers.hpp and boost/interprocess/sync/posix/interprocess_mutex.hpp to use robust mutexes, and to handle somehow the EOWNERDEAD return from pthread_mutex_lock. If you are on some other platform, you … Read more

Can an Android AsyncTask doInBackground be synchronized to serialize the task execution?

Ideally, I’d like to be able to use AsyncTask.executeOnExecutor() with a SERIAL_EXECUTOR, but this is only available for API level 11 or above: new AsyncTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, params); To target the Android APIs below level 11, I ended up implementing a custom class which encapsulates an ExecutorService with a thread pool size of 1. The full code … Read more

Best tool for synchronizing MySQL databases [closed]

I’ve been using SQLyog for years now. Recently they released v8.0 which includes an updated interface and two very cool features the Query Profiler and SQL Formatter. The formatter was the reason I upgraded this year. http://www.webyog.com/en/sqlyog_feature_list.php Blog post with video and animated gif of the SQL Formatter in action http://www.webyog.com/blog/2009/02/02/profile-and-format-mysql-queries-with-the-new-sqlyog-80/ A few years ago … Read more

Synchronizing 2 processes using interprocess synchronizations objects – Mutex or AutoResetEvent

I was just going to edit this answer, but it doesn’t seem correct. So I’ll post my own… According to the Threads for C# page, which has a lot of synchronization tutorials, AutoResetEvent cannot be used for interprocess synchronization. However, a named EventWaitHandle can be used for interprocess synchronization. In the above page, visit the … Read more

Sync Android devices via GPS time?

You can get the time difference in milliseconds from currentTimeMillis() and Location.getTime() in the onLocationChanged() callback. Use requestSingleUpdate() I just want to add that, if the user has a data connection they can use NTP time, which is even more accurate, as the GPS internal clock might drift and correcting it takes a while. EDIT: … Read more