Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ACE_MEM_IO_H
00015 #define ACE_MEM_IO_H
00016 #include "ace/pre.h"
00017
00018 #include "ace/ACE_export.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00025
00026 #include "ace/SOCK.h"
00027 #include "ace/MEM_SAP.h"
00028 #include "ace/Message_Block.h"
00029 #include "ace/Process_Semaphore.h"
00030 #include "ace/Process_Mutex.h"
00031
00032
00033 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00034
00035 class ACE_Export ACE_Reactive_MEM_IO : public ACE_MEM_SAP
00036 {
00037 public:
00038 ACE_Reactive_MEM_IO (void);
00039
00040 virtual ~ACE_Reactive_MEM_IO (void);
00041
00042
00043
00044
00045
00046
00047
00048 virtual int init (ACE_HANDLE handle,
00049 const ACE_TCHAR *name,
00050 MALLOC_OPTIONS *options);
00051
00052
00053
00054
00055
00056
00057 virtual ssize_t recv_buf (ACE_MEM_SAP_Node *&buf,
00058 int flags,
00059 const ACE_Time_Value *timeout);
00060
00061
00062
00063
00064
00065 virtual ssize_t send_buf (ACE_MEM_SAP_Node *buf,
00066 int flags,
00067 const ACE_Time_Value *timeout);
00068
00069
00070
00071
00072
00073
00074 ssize_t get_buf_len (const ACE_OFF_T off, ACE_MEM_SAP_Node *&buf);
00075 };
00076
00077 #if defined (ACE_WIN32) || !defined (_ACE_USE_SV_SEM)
00078 class ACE_Export ACE_MT_MEM_IO : public ACE_MEM_SAP
00079 {
00080 public:
00081 typedef struct
00082 {
00083 ACE_MEM_SAP_Node::ACE_MEM_SAP_NODE_PTR head_;
00084 ACE_MEM_SAP_Node::ACE_MEM_SAP_NODE_PTR tail_;
00085 } MQ_Struct;
00086
00087 class Simple_Queue
00088 {
00089 public:
00090 Simple_Queue (void);
00091 Simple_Queue (MQ_Struct *mq);
00092
00093 int init (MQ_Struct *mq, ACE_MEM_SAP::MALLOC_TYPE *malloc);
00094
00095 int write (ACE_MEM_SAP_Node *new_msg);
00096
00097 ACE_MEM_SAP_Node *read (void);
00098 private:
00099 MQ_Struct *mq_;
00100 ACE_MEM_SAP::MALLOC_TYPE *malloc_;
00101 };
00102
00103 typedef struct
00104 {
00105 ACE_SYNCH_PROCESS_SEMAPHORE *sema_;
00106 ACE_SYNCH_PROCESS_MUTEX *lock_;
00107 Simple_Queue queue_;
00108 } Channel;
00109
00110 ACE_MT_MEM_IO (void);
00111
00112 virtual ~ACE_MT_MEM_IO (void);
00113
00114
00115
00116
00117 virtual int init (ACE_HANDLE handle,
00118 const ACE_TCHAR *name,
00119 MALLOC_OPTIONS *options);
00120
00121
00122
00123
00124
00125
00126 virtual ssize_t recv_buf (ACE_MEM_SAP_Node *&buf,
00127 int flags,
00128 const ACE_Time_Value *timeout);
00129
00130
00131
00132
00133
00134 virtual ssize_t send_buf (ACE_MEM_SAP_Node *buf,
00135 int flags,
00136 const ACE_Time_Value *timeout);
00137
00138 private:
00139 Channel recv_channel_;
00140 Channel send_channel_;
00141 };
00142 #endif
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 class ACE_Export ACE_MEM_IO : public ACE_SOCK
00171 {
00172 public:
00173
00174
00175 ACE_MEM_IO (void);
00176
00177
00178 ~ACE_MEM_IO (void);
00179
00180 typedef enum
00181 {
00182 Reactive,
00183 MT
00184 } Signal_Strategy;
00185
00186
00187
00188
00189 int init (const ACE_TCHAR *name,
00190 ACE_MEM_IO::Signal_Strategy type = ACE_MEM_IO::Reactive,
00191 ACE_MEM_SAP::MALLOC_OPTIONS *options = 0);
00192
00193
00194
00195
00196
00197 int fini (void);
00198
00199
00200
00201 ssize_t send (const void *buf,
00202 size_t n,
00203 int flags) ;
00204
00205
00206 ssize_t recv (void *buf,
00207 size_t n,
00208 int flags) ;
00209
00210
00211
00212 ssize_t send (const void *buf,
00213 size_t n) ;
00214
00215
00216 ssize_t recv (void *buf,
00217 size_t n) ;
00218
00219
00220
00221
00222
00223
00224
00225 ssize_t send (const void *buf,
00226 size_t n,
00227 const ACE_Time_Value *timeout);
00228
00229
00230
00231
00232
00233
00234
00235 ssize_t send (const void *buf,
00236 size_t n,
00237 int flags,
00238 const ACE_Time_Value *timeout);
00239
00240
00241
00242
00243
00244
00245 ssize_t send (const ACE_Message_Block *message_block,
00246 const ACE_Time_Value *timeout);
00247
00248
00249
00250
00251
00252
00253
00254 ssize_t recv (void *buf,
00255 size_t n,
00256 const ACE_Time_Value *timeout);
00257
00258
00259
00260
00261
00262
00263
00264 ssize_t recv (void *buf,
00265 size_t n,
00266 int flags,
00267 const ACE_Time_Value *timeout);
00268
00269
00270
00271 void dump (void) const;
00272
00273
00274 ACE_ALLOC_HOOK_DECLARE;
00275
00276
00277
00278
00279
00280
00281
00282 int get_remote_port (u_short &) const;
00283 */
00284
00285 private:
00286 ssize_t fetch_recv_buf (int flag, const ACE_Time_Value *timeout);
00287
00288
00289 ACE_MEM_SAP *deliver_strategy_;
00290
00291
00292 ACE_MEM_SAP_Node *recv_buffer_;
00293
00294
00295 ssize_t buf_size_;
00296
00297
00298 ssize_t cur_offset_;
00299 };
00300
00301 ACE_END_VERSIONED_NAMESPACE_DECL
00302
00303 #if defined (__ACE_INLINE__)
00304 #include "ace/MEM_IO.inl"
00305 #endif
00306
00307 #endif
00308
00309 #include "ace/post.h"
00310 #endif