photon  1.1
photon_msgbuffer.h
Go to the documentation of this file.
1 // =============================================================================
2 // Photon RDMA Library (libphoton)
3 //
4 // Copyright (c) 2016, Trustees of Indiana University,
5 // All rights reserved.
6 //
7 // This software may be modified and distributed under the terms of the BSD
8 // license. See the COPYING file for details.
9 //
10 // This software was created at the Indiana University Center for Research in
11 // Extreme Scale Technologies (CREST).
12 // =============================================================================
13 
14 #ifndef PHOTON_MSGBUFFER_H
15 #define PHOTON_MSGBUFFER_H
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <stdint.h>
22 #include <stdbool.h>
23 #include <pthread.h>
24 
25 #include "photon_buffer_internal.h"
26 
27 typedef struct photon_msgbuffer_entry_t {
28  void *base;
29  void *hptr;
30  void *mptr;
31  bool empty;
32 } photon_mbe;
33 
36  int p_count;
37  int s_index;
38  int status;
39 
41  uint64_t p_size;
42  uint64_t m_size;
43  int p_offset;
44  int p_hsize;
45 
46  pthread_mutex_t buf_lock;
48 
49 typedef struct photon_msgbuffer_t * photonMsgBuf;
50 
51 /*
52  @param size: - total allocated buffer space
53  @param p_size - size of the partitions (includes offset and header)
54  @param p_offset - bytes in front of each message
55  @param p_hsize - bytes of header
56 
57  .base .hptr .mptr
58  |...p_offset...|...p_hsize...|......msg......| */
59 PHOTON_INTERNAL photonMsgBuf photon_msgbuffer_new(uint64_t size, uint64_t p_size, int p_offset, int p_hsize);
60 PHOTON_INTERNAL int photon_msgbuffer_free(photonMsgBuf mbuf);
61 PHOTON_INTERNAL photon_mbe *photon_msgbuffer_get_entry(photonMsgBuf mbuf, int *ind);
62 PHOTON_INTERNAL int photon_msgbuffer_free_entry(photonMsgBuf mbuf, int ind);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif
PHOTON_INTERNAL photonMsgBuf photon_msgbuffer_new(uint64_t size, uint64_t p_size, int p_offset, int p_hsize)
PHOTON_INTERNAL photon_mbe * photon_msgbuffer_get_entry(photonMsgBuf mbuf, int *ind)
struct photon_msgbuffer_t photon_msgbuf
struct photon_buffer_handle_t * photonBufferHandle
photonBufferHandle db
pthread_mutex_t buf_lock
PHOTON_INTERNAL int photon_msgbuffer_free_entry(photonMsgBuf mbuf, int ind)
PHOTON_INTERNAL int photon_msgbuffer_free(photonMsgBuf mbuf)
#define PHOTON_INTERNAL
photon_mbe * entries