Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[s4u] Allocate Mailbox on the heap and return MailboxPtr
[simgrid.git] / src / simix / smx_network_private.h
1 /* Copyright (c) 2007-2010, 2012-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _SIMIX_NETWORK_PRIVATE_H
8 #define _SIMIX_NETWORK_PRIVATE_H
9
10 #include <deque>
11 #include <string>
12
13 #include <boost/intrusive_ptr.hpp>
14
15 #include <xbt/base.h>
16
17 #include <simgrid/s4u/mailbox.hpp>
18
19 #include "simgrid/simix.h"
20 #include "popping_private.h"
21 #include "src/simix/smx_process_private.h"
22
23 namespace simgrid {
24 namespace simix {
25
26 /** @brief Rendez-vous point datatype */
27
28 class Mailbox {
29 public:
30   Mailbox(const char* name) : mbox_(this), name(xbt_strdup(name)) {}
31   ~Mailbox() {
32     xbt_free(name);
33   }
34
35   simgrid::s4u::Mailbox mbox_;
36   char* name;
37   std::deque<smx_synchro_t> comm_queue;
38   boost::intrusive_ptr<simgrid::simix::Process> permanent_receiver; //process which the mailbox is attached to
39   std::deque<smx_synchro_t> done_comm_queue;//messages already received in the permanent receive mode
40 };
41
42 }
43 }
44
45 XBT_PRIVATE void SIMIX_mailbox_exit(void);
46
47 XBT_PRIVATE smx_mailbox_t SIMIX_mbox_create(const char *name);
48 XBT_PRIVATE smx_mailbox_t SIMIX_mbox_get_by_name(const char *name);
49 XBT_PRIVATE void SIMIX_mbox_remove(smx_mailbox_t mbox, smx_synchro_t comm);
50
51 XBT_PRIVATE void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t proc);
52 XBT_PRIVATE smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox,
53                               void *dst_buff, size_t *dst_buff_size,
54                               int (*match_fun)(void *, void *, smx_synchro_t),
55                               void (*copy_data_fun)(smx_synchro_t, void*, size_t),
56                               void *data, double rate);
57 XBT_PRIVATE smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src,
58                               int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data);
59
60 #endif