Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make mailbox matching functions return a bool.
[simgrid.git] / src / simix / libsmx.cpp
index 387fd23..9410c2f 100644 (file)
  *
  * @param execution The execution synchro
  */
-e_smx_state_t simcall_execution_wait(const smx_activity_t& execution)
+e_smx_state_t simcall_execution_wait(const smx_activity_t& execution, double timeout)
 {
-  return (e_smx_state_t)simcall_BODY_execution_wait(static_cast<simgrid::kernel::activity::ExecImpl*>(execution.get()));
+  return (e_smx_state_t)simcall_BODY_execution_wait(static_cast<simgrid::kernel::activity::ExecImpl*>(execution.get()),
+                                                    timeout);
 }
 
 bool simcall_execution_test(const smx_activity_t& execution)
@@ -46,7 +47,7 @@ unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl*
 
 void simcall_process_join(smx_actor_t process, double timeout) // XBT_DEPRECATED_v328
 {
-  SIMIX_process_self()->join(process, timeout);
+  simgrid::kernel::actor::ActorImpl::self()->join(process, timeout);
 }
 
 void simcall_process_suspend(smx_actor_t process) // XBT_DEPRECATED_v328
@@ -56,15 +57,15 @@ void simcall_process_suspend(smx_actor_t process) // XBT_DEPRECATED_v328
 
 e_smx_state_t simcall_process_sleep(double duration) // XBT_DEPRECATED_v329
 {
-  SIMIX_process_self()->sleep(duration);
-  return SIMIX_DONE;
+  simgrid::kernel::actor::ActorImpl::self()->sleep(duration);
+  return simgrid::kernel::activity::State::DONE;
 }
 
 /**
  * @ingroup simix_comm_management
  */
 void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
-                       size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                       size_t src_buff_size, bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                        void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
                        double timeout)
 {
@@ -94,7 +95,7 @@ void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size,
  */
 smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
                                   size_t src_buff_size,
-                                  int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                  bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                   void (*clean_fun)(void*),
                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                   void* data, bool detached)
@@ -113,7 +114,7 @@ smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double
  * @ingroup simix_comm_management
  */
 void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
-                       int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                       bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                        void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data,
                        double timeout, double rate)
 {
@@ -137,7 +138,7 @@ void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff,
  * @ingroup simix_comm_management
  */
 smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
-                                  int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
+                                  bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
                                   void* data, double rate)
 {
@@ -151,7 +152,7 @@ smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void
  * @ingroup simix_comm_management
  */
 smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type,
-                                   int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data)
+                                   bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data)
 {
   xbt_assert(mbox, "No rendez-vous point defined for iprobe");
 
@@ -302,20 +303,25 @@ int simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
   return simcall_BODY_sem_acquire_timeout(sem, timeout);
 }
 
-e_smx_state_t simcall_io_wait(const smx_activity_t& io)
+e_smx_state_t simcall_io_wait(const smx_activity_t& io, double timeout)
 {
-  return (e_smx_state_t)simcall_BODY_io_wait(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()));
+  return (e_smx_state_t)simcall_BODY_io_wait(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()), timeout);
+}
+
+bool simcall_io_test(const smx_activity_t& io)
+{
+  return simcall_BODY_io_test(static_cast<simgrid::kernel::activity::IoImpl*>(io.get()));
 }
 
 void simcall_run_kernel(std::function<void()> const& code, simgrid::mc::SimcallInspector* t)
 {
-  SIMIX_process_self()->simcall.inspector_ = t;
+  simgrid::kernel::actor::ActorImpl::self()->simcall.inspector_ = t;
   simcall_BODY_run_kernel(&code);
 }
 
 void simcall_run_blocking(std::function<void()> const& code, simgrid::mc::SimcallInspector* t = nullptr)
 {
-  SIMIX_process_self()->simcall.inspector_ = t;
+  simgrid::kernel::actor::ActorImpl::self()->simcall.inspector_ = t;
   simcall_BODY_run_blocking(&code);
 }