Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add Message queue abstraction
[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   MessImpl* start();
40   void set_exception(actor::ActorImpl* issuer) override {};
41   void finish() override;
42
43   actor::ActorImplPtr src_actor_ = nullptr;
44   actor::ActorImplPtr dst_actor_ = nullptr;
45 };
46 } // namespace simgrid::kernel::activity
47
48 #endif