include include/simgrid/actor.h
include include/simgrid/barrier.h
include include/simgrid/chrono.hpp
+include include/simgrid/cond.h
include include/simgrid/config.h.in
include include/simgrid/engine.h
include include/simgrid/forward.h
include include/simgrid/mailbox.h
include include/simgrid/modelchecker.h
include include/simgrid/msg.h
+include include/simgrid/mutex.h
include include/simgrid/plugins/dvfs.h
include include/simgrid/plugins/energy.h
include include/simgrid/plugins/file_system.h
--- /dev/null
+/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef INCLUDE_SIMGRID_COND_H_
+#define INCLUDE_SIMGRID_COND_H_
+
+#include <simgrid/forward.h>
+
+/* C interface */
+SG_BEGIN_DECL()
+/** @brief Creates a condition variable */
+XBT_PUBLIC sg_cond_t sg_cond_init();
+
+/** @brief Blocks onto the given condition variable */
+XBT_PUBLIC void sg_cond_wait(sg_cond_t cond, sg_mutex_t mutex);
+/** @brief Blocks onto the given condition variable, but only for the given amount of time.
+ * @return 0 on success, 1 on timeout */
+XBT_PUBLIC int sg_cond_wait_for(sg_cond_t cond, sg_mutex_t mutex, double delay);
+/** @brief Signals the given mutex variable */
+XBT_PUBLIC void sg_cond_notify_one(sg_cond_t cond);
+/** @brief Broadcasts the given mutex variable */
+XBT_PUBLIC void sg_cond_notify_all(sg_cond_t cond);
+/** @brief Destroys the given mutex variable */
+XBT_PUBLIC void sg_cond_destroy(sg_cond_t cond);
+
+SG_END_DECL()
+
+#endif /* INCLUDE_SIMGRID_COND_H_ */
typedef simgrid::s4u::Host s4u_Host;
typedef simgrid::s4u::Link s4u_Link;
typedef simgrid::s4u::File s4u_File;
+typedef simgrid::s4u::ConditionVariable s4u_ConditionVariable;
typedef simgrid::s4u::Mutex s4u_Mutex;
typedef simgrid::s4u::Semaphore s4u_Semaphore;
typedef simgrid::s4u::Storage s4u_Storage;
typedef struct s4u_Host s4u_Host;
typedef struct s4u_Link s4u_Link;
typedef struct s4u_File s4u_File;
+typedef struct s4u_ConditionVariable s4u_ConditionVariable;
typedef struct s4u_Mutex s4u_Mutex;
typedef struct s4u_Semaphore s4u_Semaphore;
typedef struct s4u_Storage s4u_Storage;
#endif
typedef s4u_Barrier* sg_bar_t;
+typedef s4u_ConditionVariable* sg_cond_t;
typedef s4u_Mutex* sg_mutex_t;
typedef s4u_Semaphore* sg_sem_t;
typedef s4u_NetZone* sg_netzone_t;
friend kernel::activity::ConditionVariableImpl;
kernel::activity::ConditionVariableImpl* const cond_;
- explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {}
-
public:
+ explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {}
ConditionVariable(ConditionVariable const&) = delete;
ConditionVariable& operator=(ConditionVariable const&) = delete;
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "simgrid/cond.h"
+#include "simgrid/forward.h"
#include "simgrid/s4u/ConditionVariable.hpp"
#include "simgrid/simix.h"
#include "src/kernel/activity/ConditionVariableImpl.hpp"
} // namespace s4u
} // namespace simgrid
+
+/* **************************** Public C interface *************************** */
+sg_cond_t sg_cond_init()
+{
+ simgrid::kernel::activity::ConditionVariableImpl* cond =
+ simgrid::simix::simcall([] { return new simgrid::kernel::activity::ConditionVariableImpl(); });
+
+ return new simgrid::s4u::ConditionVariable(cond);
+}
+
+void sg_cond_wait(sg_cond_t cond, sg_mutex_t mutex)
+{
+ cond->wait(mutex);
+}
+
+int sg_cond_wait_for(sg_cond_t cond, sg_mutex_t mutex, double delay)
+{
+ std::unique_lock<simgrid::s4u::Mutex> lock(*mutex);
+ return static_cast<int>(cond->wait_for(lock, delay));
+}
+
+void sg_cond_notify_one(sg_cond_t cond)
+{
+ cond->notify_one();
+}
+
+void sg_cond_notify_all(sg_cond_t cond)
+{
+ cond->notify_all();
+}
+
+void sg_cond_destroy(sg_cond_t cond)
+{
+ delete cond;
+}
include/simgrid/kernel/future.hpp
include/simgrid/host.h
include/simgrid/link.h
+ include/simgrid/cond.h
include/simgrid/mutex.h
include/simgrid/semaphore.h
include/simgrid/storage.h