#ifndef _G_THREAD_ROCCAT_HELPER_H_
#define _G_THREAD_ROCCAT_HELPER_H_

/*
 * This file is part of roccat-tools.
 *
 * roccat-tools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * roccat-tools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with roccat-tools. If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>

G_BEGIN_DECLS

#if (GLIB_CHECK_VERSION(2, 32, 0))
	typedef GMutex GRoccatMutex;
	typedef GCond GRoccatCond;
	typedef GRecMutex GRoccatRecMutex;
#else
	typedef GMutex* GRoccatMutex;
	typedef GCond* GRoccatCond;
	typedef GStaticRecMutex GRoccatRecMutex;
#endif

GThread *g_roccat_thread_try_new(gchar const *name, GThreadFunc func, gpointer data, GError **error);

void g_roccat_mutex_init(GRoccatMutex *mutex);
void g_roccat_mutex_clear(GRoccatMutex *mutex);
void g_roccat_mutex_lock(GRoccatMutex *mutex);
void g_roccat_mutex_unlock(GRoccatMutex *mutex);

void g_roccat_cond_init(GRoccatCond *cond);
void g_roccat_cond_clear(GRoccatCond *cond);
void g_roccat_cond_wait(GRoccatCond *cond, GRoccatMutex *mutex);
void g_roccat_cond_signal(GRoccatCond *cond);

void g_roccat_rec_mutex_init(GRoccatRecMutex *mutex);
void g_roccat_rec_mutex_clear(GRoccatRecMutex *mutex);
void g_roccat_rec_mutex_lock(GRoccatRecMutex *mutex);
void g_roccat_rec_mutex_unlock(GRoccatRecMutex *mutex);

G_END_DECLS

#endif
