1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_KERNEL_ACTIVITY_COMM_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_COMM_HPP
9 #include "src/kernel/activity/ActivityImpl.hpp"
10 #include "src/kernel/actor/ActorImpl.hpp"
11 #include "surf/surf.hpp"
18 class XBT_PUBLIC CommImpl : public ActivityImpl_T<CommImpl> {
26 enum class Type { SEND = 0, RECEIVE, READY, DONE };
28 CommImpl& set_type(CommImpl::Type type);
29 CommImpl& set_size(double size);
30 CommImpl& set_src_buff(void* buff, size_t size);
31 CommImpl& set_dst_buff(void* buff, size_t* size);
32 CommImpl& set_rate(double rate);
33 double get_rate() { return rate_; }
38 void suspend() override;
39 void resume() override;
40 void cancel() override;
42 void finish() override;
44 CommImpl::Type type_; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
45 MailboxImpl* mbox = nullptr; /* Rendez-vous where the comm is queued */
48 MailboxImpl* mbox_cpy = nullptr; /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
49 (comm.mbox set to nullptr when the communication is removed from the mailbox
50 (used as garbage collector)) */
52 bool detached_ = false; /* If detached or not */
54 void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */
55 int (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when
56 looking if a given communication matches my needs. For that, myself must match the
57 expectations of the other side, too. See */
58 void (*copy_data_fun)(CommImpl*, void*, size_t) = nullptr;
60 /* Surf action data */
61 resource::Action* src_timeout_ = nullptr; /* Surf's actions to instrument the timeouts */
62 resource::Action* dst_timeout_ = nullptr; /* Surf's actions to instrument the timeouts */
63 actor::ActorImplPtr src_actor_ = nullptr;
64 actor::ActorImplPtr dst_actor_ = nullptr;
66 /* Data to be transfered */
67 void* src_buff_ = nullptr;
68 void* dst_buff_ = nullptr;
69 size_t src_buff_size_ = 0;
70 size_t* dst_buff_size_ = nullptr;
71 bool copied = false; /* whether the data were already copied */
73 void* src_data_ = nullptr; /* User data associated to the communication */
74 void* dst_data_ = nullptr;
76 } // namespace activity
78 } // namespace simgrid