# include "pantasks.h"

/* mutex to lock Client table operations */
static pthread_mutex_t ClientMutex = PTHREAD_MUTEX_INITIALIZER;

void ClientLock () {
  pthread_mutex_lock (&ClientMutex);
}

void ClientUnlock () {
  pthread_mutex_unlock (&ClientMutex);
}

/* mutex to lock Command / Multicommand operations */
static pthread_mutex_t CommandMutex = PTHREAD_MUTEX_INITIALIZER;

void CommandLock () {
  //  fprintf (stderr, "command lock\n");
  pthread_mutex_lock (&CommandMutex);
}

void CommandUnlock () {
  //  fprintf (stderr, "command unlock\n");
  pthread_mutex_unlock (&CommandMutex);
}

/* mutex to lock Control operations */
static pthread_mutex_t ControlMutex = PTHREAD_MUTEX_INITIALIZER;

void ControlLock (char *func) {
  // fprintf (stderr, "control lock %s\n", func);
  pthread_mutex_lock (&ControlMutex);
}

void ControlUnlock (char *func) {
  // fprintf (stderr, "control unlock %s\n", func);
  pthread_mutex_unlock (&ControlMutex);
}

/* mutex to lock Job / Task operations */
static pthread_mutex_t JobTaskMutex = PTHREAD_MUTEX_INITIALIZER;

void JobTaskLock () {
  //  fprintf (stderr, "jobtask lock\n");
  pthread_mutex_lock (&JobTaskMutex);
}

void JobTaskUnlock () {
  //  fprintf (stderr, "jobtask unlock\n");
  pthread_mutex_unlock (&JobTaskMutex);
}

