1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
|
/* -*- C++ -*- */
//=============================================================================
/**
* @file Asynch_IO_Impl.h
*
* $Id$
*
*
* This class contains asbtract base classes for all the concrete
* implementation classes for the various asynchronous operations
* that are used with the Praoctor.
*
*
* @author Irfan Pyarali (irfan@cs.wustl.edu)
* @author Tim Harrison (harrison@cs.wustl.edu)
* @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
*/
//=============================================================================
#ifndef ACE_ASYNCH_IO_IMPL_H
#define ACE_ASYNCH_IO_IMPL_H
#include "ace/pre.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS))
// This only works on Win32 platforms and on Unix platforms supporting
// aio calls.
#include "ace/Asynch_IO.h"
// Forward declaration.
class ACE_Proactor_Impl;
/**
* @class ACE_Asynch_Result_Impl
*
* @brief Abstract base class for the all the classes that provide
* concrete implementations for ACE_Asynch_Result.
*
*/
class ACE_Export ACE_Asynch_Result_Impl
{
public:
virtual ~ACE_Asynch_Result_Impl (void);
/// Number of bytes transferred by the operation.
virtual u_long bytes_transferred (void) const = 0;
/// ACT associated with the operation.
virtual const void *act (void) const = 0;
/// Did the operation succeed?
virtual int success (void) const = 0;
/// This ACT is not the same as the ACT associated with the
/// asynchronous operation.
virtual const void *completion_key (void) const = 0;
/// Error value if the operation fail.
virtual u_long error (void) const = 0;
/// Event associated with the OVERLAPPED structure.
virtual ACE_HANDLE event (void) const = 0;
/// This really make sense only when doing file I/O.
virtual u_long offset (void) const = 0;
virtual u_long offset_high (void) const = 0;
/// Priority of the operation.
virtual int priority (void) const = 0;
/**
* POSIX4 real-time signal number to be used for the
* operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By
* default, SIGRTMIN is used to issue <aio_> calls. This is a no-op
* on non-POSIX4 systems and returns 0.
*/
virtual int signal_number (void) const = 0;
// protected:
//
// These two should really be protected. But sometimes it
// simplifies code to be able to "fake" a result. Use carefully.
/// This is called when the asynchronous operation completes.
virtual void complete (u_long bytes_transferred,
int success,
const void *completion_key,
u_long error = 0) = 0;
/// Post <this> to the Proactor's completion port.
virtual int post_completion (ACE_Proactor_Impl *proactor) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Result_Impl (void);
};
/**
* @class ACE_Asynch_Operation_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Operation.
*/
class ACE_Export ACE_Asynch_Operation_Impl
{
public:
virtual ~ACE_Asynch_Operation_Impl (void);
/**
* Initializes the factory with information which will be used with
* each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
* <ACE_Handler::handle> will be called on the <handler> to get the
* correct handle.
*/
virtual int open (ACE_Handler &handler,
ACE_HANDLE handle,
const void *completion_key,
ACE_Proactor *proactor) = 0;
/**
* This cancels all pending accepts operations that were issued by
* the calling thread. The function does not cancel asynchronous
* operations issued by other threads.
*/
virtual int cancel (void) = 0;
// = Access methods.
/// Return the underlying proactor.
virtual ACE_Proactor* proactor (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Operation_Impl (void);
};
/**
* @class ACE_Asynch_Read_Stream_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Read_Stream
*
*/
class ACE_Export ACE_Asynch_Read_Stream_Impl : public virtual ACE_Asynch_Operation_Impl
{
public:
virtual ~ACE_Asynch_Read_Stream_Impl (void);
/// This starts off an asynchronous read. Upto <bytes_to_read> will
/// be read and stored in the <message_block>.
virtual int read (ACE_Message_Block &message_block,
u_long bytes_to_read,
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_Stream_Impl (void);
};
/**
* @class ACE_Asynch_Read_Stream_Result_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Read_Stream::Result class.
*
*/
class ACE_Export ACE_Asynch_Read_Stream_Result_Impl : public virtual ACE_Asynch_Result_Impl
{
public:
virtual ~ACE_Asynch_Read_Stream_Result_Impl (void);
/// The number of bytes which were requested at the start of the
/// asynchronous read.
virtual u_long bytes_to_read (void) const = 0;
/// Message block which contains the read data.
virtual ACE_Message_Block &message_block (void) const = 0;
/// I/O handle used for reading.
virtual ACE_HANDLE handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_Stream_Result_Impl (void);
};
/**
* @class ACE_Asynch_Write_Stream_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Write_Stream class.
*
*/
class ACE_Export ACE_Asynch_Write_Stream_Impl : public virtual ACE_Asynch_Operation_Impl
{
public:
virtual ~ACE_Asynch_Write_Stream_Impl (void);
/// This starts off an asynchronous write. Upto <bytes_to_write>
/// will be written from the <message_block>.
virtual int write (ACE_Message_Block &message_block,
u_long bytes_to_write,
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_Stream_Impl (void);
};
/**
* @class ACE_Asynch_Write_Stream_Result_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Write_Stream::Result.
*
*/
class ACE_Export ACE_Asynch_Write_Stream_Result_Impl : public virtual ACE_Asynch_Result_Impl
{
public:
virtual ~ACE_Asynch_Write_Stream_Result_Impl (void);
/// The number of bytes which were requested at the start of the
/// asynchronous write.
virtual u_long bytes_to_write (void) const = 0;
/// Message block that contains the data to be written.
virtual ACE_Message_Block &message_block (void) const = 0;
/// I/O handle used for writing.
virtual ACE_HANDLE handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_Stream_Result_Impl (void);
};
/**
* @class ACE_Asynch_Read_File_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Read_File::Result.
*
*/
class ACE_Export ACE_Asynch_Read_File_Impl : public virtual ACE_Asynch_Read_Stream_Impl
{
public:
virtual ~ACE_Asynch_Read_File_Impl (void);
/**
* This starts off an asynchronous read. Upto <bytes_to_read> will
* be read and stored in the <message_block>. The read will start
* at <offset> from the beginning of the file.
*/
virtual int read (ACE_Message_Block &message_block,
u_long bytes_to_read,
u_long offset,
u_long offset_high,
const void *act,
int priority,
int signal_number) = 0;
// We don;t need to redefine the following function again because it
// has already been defined in ACE_Asynch_Read_Stream_Impl. But we
// still need it here to supress a overwriting pure virtual function
// warning in KAI compiler.
/// This starts off an asynchronous read. Upto <bytes_to_read> will
/// be read and stored in the <message_block>.
virtual int read (ACE_Message_Block &message_block,
u_long bytes_to_read,
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_File_Impl (void);
};
/**
* @class ACE_Asynch_Read_File_Result_Impl
*
* @brief This is the abstract base class for all the concrete
* implementation classes for ACE_Asynch_Read_File::Result.
*
*/
class ACE_Export ACE_Asynch_Read_File_Result_Impl : public virtual ACE_Asynch_Read_Stream_Result_Impl
{
public:
/// Destructor.
virtual ~ACE_Asynch_Read_File_Result_Impl (void);
protected:
/// Do-nothing constructor.
ACE_Asynch_Read_File_Result_Impl (void);
};
/**
* @class ACE_Asynch_Write_File_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Write_File.
*
*/
class ACE_Export ACE_Asynch_Write_File_Impl : public virtual ACE_Asynch_Write_Stream_Impl
{
public:
virtual ~ACE_Asynch_Write_File_Impl (void);
/**
* This starts off an asynchronous write. Upto <bytes_to_write>
* will be write and stored in the <message_block>. The write will
* start at <offset> from the beginning of the file.
*/
virtual int write (ACE_Message_Block &message_block,
u_long bytes_to_write,
u_long offset,
u_long offset_high,
const void *act,
int priority,
int signal_number) = 0;
// We don;t need to redefine the following function again because it
// has already been defined in ACE_Asynch_Write_Stream_Impl. But we
// still need it here to supress a overwriting pure virtual function
// warning in KAI compiler.
/// This starts off an asynchronous write. Upto <bytes_to_write>
/// will be written from the <message_block>.
virtual int write (ACE_Message_Block &message_block,
u_long bytes_to_write,
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_File_Impl (void);
};
/**
* @class ACE_Asynch_Write_File_Result_Impl
*
* @brief This is the abstract base class for all the concrete
* implementation classes that provide different implementations
* for the ACE_Asynch_Write_File::Result.
*
*/
class ACE_Export ACE_Asynch_Write_File_Result_Impl : public virtual ACE_Asynch_Write_Stream_Result_Impl
{
public:
virtual ~ACE_Asynch_Write_File_Result_Impl (void);
protected:
/// Do-nothing constructor.
ACE_Asynch_Write_File_Result_Impl (void);
};
/**
* @class ACE_Asynch_Accept_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Accept.
*
*/
class ACE_Export ACE_Asynch_Accept_Impl : public virtual ACE_Asynch_Operation_Impl
{
public:
virtual ~ACE_Asynch_Accept_Impl (void);
/**
* This starts off an asynchronous accept. The asynchronous accept
* call also allows any initial data to be returned to the
* <handler>. Upto <bytes_to_read> will be read and stored in the
* <message_block>. The <accept_handle> will be used for the
* <accept> call. If (<accept_handle> == INVALID_HANDLE), a new
* handle will be created.
*
* <message_block> must be specified. This is because the address of
* the new connection is placed at the end of this buffer.
*/
virtual int accept (ACE_Message_Block &message_block,
u_long bytes_to_read,
ACE_HANDLE accept_handle,
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Accept_Impl (void);
};
/**
* @class ACE_Asynch_Accept_Result_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Accept.
*
*/
class ACE_Export ACE_Asynch_Accept_Result_Impl : public virtual ACE_Asynch_Result_Impl
{
public:
virtual ~ACE_Asynch_Accept_Result_Impl (void);
/// The number of bytes which were requested at the start of the
/// asynchronous accept.
virtual u_long bytes_to_read (void) const = 0;
/// Message block which contains the read data.
virtual ACE_Message_Block &message_block (void) const = 0;
/// I/O handle used for accepting new connections.
virtual ACE_HANDLE listen_handle (void) const = 0;
/// I/O handle for the new connection.
virtual ACE_HANDLE accept_handle (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Accept_Result_Impl (void);
};
/**
* @class ACE_Asynch_Transmit_File_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Transmit_File.
*
*/
class ACE_Asynch_Transmit_File_Impl : public virtual ACE_Asynch_Operation_Impl
{
public:
virtual ~ACE_Asynch_Transmit_File_Impl (void);
/// This starts off an asynchronous transmit file.
virtual int transmit_file (ACE_HANDLE file,
ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
u_long bytes_to_write,
u_long offset,
u_long offset_high,
u_long bytes_per_send,
u_long flags,
const void *act,
int priority,
int signal_number) = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Transmit_File_Impl (void);
};
/**
* @class ACE_Asynch_Transmit_File_Result_Impl
*
* @brief Abstract base class for all the concrete implementation
* classes that provide different implementations for the
* ACE_Asynch_Transmit_File::Result.
*
*/
class ACE_Export ACE_Asynch_Transmit_File_Result_Impl : public virtual ACE_Asynch_Result_Impl
{
public:
virtual ~ACE_Asynch_Transmit_File_Result_Impl (void);
/// Socket used for transmitting the file.
virtual ACE_HANDLE socket (void) const = 0;
/// File from which the data is read.
virtual ACE_HANDLE file (void) const = 0;
/// Header and trailer data associated with this transmit file.
virtual ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer (void) const = 0;
/// The number of bytes which were requested at the start of the
/// asynchronous transmit file.
virtual u_long bytes_to_write (void) const = 0;
/// Number of bytes per send requested at the start of the transmit
/// file.
virtual u_long bytes_per_send (void) const = 0;
/// Flags which were passed into transmit file.
virtual u_long flags (void) const = 0;
protected:
/// Do-nothing constructor.
ACE_Asynch_Transmit_File_Result_Impl (void);
};
#if defined (__ACE_INLINE__)
#include "ace/Asynch_IO_Impl.i"
#endif /* __ACE_INLINE__ */
#endif /* ACE_HAS_AIO_CALLS || !ACE_HAS_WINCE && ACE_WIN32 */
#include "ace/post.h"
#endif /* ACE_ASYNCH_IO_IMPL_H */
|