Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
strenghten the behavior of Message queues after some Wrench breaking
[simgrid.git] / src / kernel / activity / MessImpl.hpp
1 /* Copyright (c) 2023. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef SIMGRID_KERNEL_ACTIVITY_MESS_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_MESS_HPP
8
9 #include "src/kernel/activity/ActivityImpl.hpp"
10 #include "src/kernel/actor/ActorImpl.hpp"
11 #include "src/kernel/actor/CommObserver.hpp"
12
13 namespace simgrid::kernel::activity {
14
15 enum class MessImplType { PUT, GET };
16
17 class XBT_PUBLIC MessImpl : public ActivityImpl_T<MessImpl> {
18   ~MessImpl() override;
19
20   MessageQueueImpl* queue_ = nullptr;
21   void* payload_           = nullptr;
22   MessImplType type_       = MessImplType::PUT;
23   unsigned char* dst_buff_ = nullptr;
24   size_t* dst_buff_size_   = nullptr;
25
26 public:
27   MessImpl& set_type(MessImplType type);
28   MessImplType get_type() const { return type_; }
29   MessImpl& set_payload(void* payload);
30   void* get_payload() { return payload_; }
31
32   MessImpl& set_queue(MessageQueueImpl* queue);
33   MessageQueueImpl* get_queue() const { return queue_; }
34   MessImpl& set_dst_buff(unsigned char* buff, size_t* size);
35
36   static ActivityImplPtr iput(actor::MessIputSimcall* observer);
37   static ActivityImplPtr iget(actor::MessIgetSimcall* observer);
38
39   void wait_for(actor::ActorImpl* issuer, double timeout) override;
40
41   MessImpl* start();
42   void suspend() override { /* no action to suspend for Mess */ }
43   void resume() override { /* no action to resume for Mess */ }
44   void cancel() override;
45   void set_exception(actor::ActorImpl* issuer) override {};
46   void finish() override;
47
48   actor::ActorImplPtr src_actor_ = nullptr;
49   actor::ActorImplPtr dst_actor_ = nullptr;
50 };
51 } // namespace simgrid::kernel::activity
52
53 #endif