2004-03-03 16:10:26 +00:00
|
|
|
/*
|
2004-11-22 01:38:40 +00:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-03-03 16:10:26 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
2004-06-07 15:33:53 +00:00
|
|
|
#ifndef OMPI_CONDITION_PTHREAD_H
|
|
|
|
#define OMPI_CONDITION_PTHREAD_H
|
2004-03-03 16:10:26 +00:00
|
|
|
|
2004-10-20 01:03:09 +00:00
|
|
|
#ifdef HAVE_PTHREAD_H
|
2004-03-03 16:10:26 +00:00
|
|
|
#include <pthread.h>
|
2004-10-20 01:03:09 +00:00
|
|
|
#endif
|
2005-07-03 22:45:48 +00:00
|
|
|
#include "opal/threads/mutex.h"
|
2004-03-03 16:10:26 +00:00
|
|
|
|
2004-10-20 22:31:03 +00:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2005-07-03 22:45:48 +00:00
|
|
|
struct opal_condition_t {
|
2005-07-03 16:06:07 +00:00
|
|
|
opal_object_t super;
|
2004-03-03 16:10:26 +00:00
|
|
|
pthread_cond_t c_cond;
|
|
|
|
};
|
2005-07-03 22:45:48 +00:00
|
|
|
typedef struct opal_condition_t opal_condition_t;
|
2004-03-03 16:10:26 +00:00
|
|
|
|
2005-07-03 22:45:48 +00:00
|
|
|
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(opal_condition_t);
|
2004-03-03 16:10:26 +00:00
|
|
|
|
|
|
|
|
2005-07-03 22:45:48 +00:00
|
|
|
static inline int opal_condition_wait(opal_condition_t *c, opal_mutex_t *m)
|
2004-03-03 16:10:26 +00:00
|
|
|
{
|
2004-08-19 19:29:01 +00:00
|
|
|
return pthread_cond_wait(&c->c_cond, &m->m_lock_pthread);
|
2004-03-03 16:10:26 +00:00
|
|
|
}
|
|
|
|
|
2005-07-03 22:45:48 +00:00
|
|
|
static inline int opal_condition_timedwait(opal_condition_t *c,
|
|
|
|
opal_mutex_t *m,
|
2004-08-19 19:29:01 +00:00
|
|
|
const struct timespec *abstime)
|
2004-03-03 16:10:26 +00:00
|
|
|
{
|
2004-08-19 19:29:01 +00:00
|
|
|
return pthread_cond_timedwait(&c->c_cond, &m->m_lock_pthread, abstime);
|
2004-03-03 16:10:26 +00:00
|
|
|
}
|
|
|
|
|
2005-07-03 22:45:48 +00:00
|
|
|
static inline int opal_condition_signal(opal_condition_t *c)
|
2004-03-03 16:10:26 +00:00
|
|
|
{
|
|
|
|
return pthread_cond_signal(&c->c_cond);
|
|
|
|
}
|
|
|
|
|
2005-07-03 22:45:48 +00:00
|
|
|
static inline int opal_condition_broadcast(opal_condition_t *c)
|
2004-03-03 16:10:26 +00:00
|
|
|
{
|
|
|
|
return pthread_cond_broadcast(&c->c_cond);
|
|
|
|
}
|
|
|
|
|
2004-10-20 22:31:03 +00:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
2004-03-03 16:10:26 +00:00
|
|
|
#endif
|
|
|
|
|