summaryrefslogtreecommitdiff
path: root/ace/MEM_SAP.h
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-04-03 05:43:25 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-04-03 05:43:25 +0000
commit2264f38af466b83af9bb555ff313d63ab8889c7a (patch)
treeea706111f1bebfc77f3256d93dc201eca34b6199 /ace/MEM_SAP.h
parenta0c03ac51ba68a66b4653dfe79c50bde616a4a36 (diff)
downloadATCD-2264f38af466b83af9bb555ff313d63ab8889c7a.tar.gz
ChangeLogTag:Mon Apr 02 23:41:34 2001 Nanbor Wang <nanbor@cs.wustl.edu>
Diffstat (limited to 'ace/MEM_SAP.h')
-rw-r--r--ace/MEM_SAP.h96
1 files changed, 74 insertions, 22 deletions
diff --git a/ace/MEM_SAP.h b/ace/MEM_SAP.h
index 1a480b81884..8f62dbb9580 100644
--- a/ace/MEM_SAP.h
+++ b/ace/MEM_SAP.h
@@ -26,8 +26,47 @@
#include "ace/Process_Mutex.h"
+class ACE_MEM_SAP;
+class ACE_Reactive_MEM_IO;
+class ACE_MT_MEM_IO;
+class ACE_MEM_IO;
+
+// Internal data structure
+// MEM_SAP uses to queue up
+// data.
+class ACE_Export ACE_MEM_SAP_Node
+{
+public:
+// friend class ACE_MEM_SAP;
+// friend class ACE_Reactive_MEM_IO;
+// friend class ACE_MT_MEM_IO;
+// friend class ACE_MEM_IO;
+
+ typedef ACE_Based_Pointer<ACE_MEM_SAP_Node> ACE_MEM_SAP_NODE_PTR;
+
+ // Initialize the node with its capacity.
+ ACE_MEM_SAP_Node (size_t cap);
+
+ // Get the size of the data we hold.
+ size_t size (void) const;
+
+ // Get the capacity of this block of data.
+ size_t capacity (void) const;
+
+ // Get the pointer to the block of data we hold.
+ void *data (void);
+
+ // The maximum size of this memory block.
+ size_t capacity_;
+
+ // The actualy size used.
+ size_t size_;
+
+ ACE_MEM_SAP_NODE_PTR next_;
+};
+
/**
- * @class ACE_MEM_SAP
+ * @Class ACE_MEM_SAP
*
* @brief Defines the methods of shared memory management for
* shared memory transport.
@@ -41,34 +80,45 @@ public:
typedef ACE_MMAP_Memory_Pool_Options MALLOC_OPTIONS;
/// Destructor.
- ~ACE_MEM_SAP (void);
+ virtual ~ACE_MEM_SAP (void);
- /// request a buffer of size <size>. Return 0 if the <shm_malloc_> is
- /// not initialized.
- void *acquire_buffer (const ssize_t size);
-
- /// release a buffer pointed by <buf>. Return -1 if the <shm_malloc_>
- /// is not initialized.
- int release_buffer (void *buf);
+ /**
+ * Initialize the MEM_SAP object.
+ */
+ virtual int init (ACE_HANDLE handle,
+ const ACE_TCHAR *name,
+ MALLOC_OPTIONS *options) = 0;
/**
- * Set the length of buf (containing information) to <n> bytes.
- * Return the offset of the <buf> relative to the base address.
- * <buf> must be acquired by <get_buffer> method. Return -1 if the
- * <shm_malloc_> is not initialized.
+ * Finalizing the MEM_SAP object. This method doesn't invoke
+ * the <remove> method.
*/
- off_t set_buf_len (void *buf,
- size_t n);
+ virtual int fini (int remove) = 0;
/**
- * Convert the buffer offset <off> to absolute address to <buf>.
- * Return the size of valid information containing in the <buf>,
- * -1 if <shm_malloc_> is not initialized.
+ * Fetch location of next available data into <recv_buffer_>.
+ * As this operation read the address of the data off the socket
+ * using ACE::recv, <timeout> only applies to ACE::recv.
*/
- ssize_t get_buf_len (const off_t off, void *&buf);
+ virtual int recv_buf (ACE_MEM_SAP_Node *&buf,
+ int flags,
+ const ACE_Time_Value *timeout) = 0;
- /// Remove the shared resouce (mmap file) used by us.
- int remove (void);
+ /**
+ * Wait to to <timeout> amount of time to send <buf>. If <send>
+ * times out a -1 is returned with <errno == ETIME>. If it succeeds
+ * the number of bytes sent is returned. */
+ virtual int send_buf (ACE_MEM_SAP_Node *buf,
+ int flags,
+ const ACE_Time_Value *timeout) = 0;
+
+ /// request a buffer of size <size>. Return 0 if the <shm_malloc_> is
+ /// not initialized.
+ ACE_MEM_SAP_Node *acquire_buffer (const ssize_t size);
+
+ /// release a buffer pointed by <buf>. Return -1 if the <shm_malloc_>
+ /// is not initialized.
+ int release_buffer (ACE_MEM_SAP_Node *buf);
/// Dump the state of an object.
void dump (void) const;
@@ -86,12 +136,14 @@ protected:
* communication.
*/
int create_shm_malloc (const ACE_TCHAR *name,
- MALLOC_OPTIONS *options = 0);
+ MALLOC_OPTIONS *options);
/// Close down the share memory pool. If <remove> != 0, then the
/// mmap file will also get removed.
int close_shm_malloc (const int remove = 0);
+ ACE_HANDLE handle_;
+
/// Data exchange channel.
MALLOC_TYPE *shm_malloc_;