AsyncIOTask Class Reference

An object representing an asynchronous I/O operation. More...

#include <AsyncIOTask.h++>

List of all members.

Public Member Functions

 AsyncIOTask ()
 Construct a new AsyncIOTask.
 ~AsyncIOTask ()
 Destructor.
bool isCompleted () throw (IOException, InterruptedException)
 Determine if the asynchronous I/O task has completed (either successfully or with an error); and, if so, determine the result of the operation.
void cancel () throw (IOException)
 Attempt to cancel the asynchronous I/O task.
void waitFor (timespan_ms_t timeout) throw (IOException, InterruptedException)
 Wait for an asynchronous I/O task to complete.
size_t getBytesTransferred () throw ()
 Get the number of bytes transferred by the I/O task.

Friends

class Stream
class AsyncIOPoller

Detailed Description

An object representing an asynchronous I/O operation.

Author:
Mark Lindner

Constructor & Destructor Documentation

AsyncIOTask (  ) 

Construct a new AsyncIOTask.

The to collect the results of the task, either:

  • Periodically call isCompleted() until that method returns true, or
  • Call waitFor() to block until the operation completes.
~AsyncIOTask (  ) 

Destructor.


Member Function Documentation

void cancel (  )  throw (IOException)

Attempt to cancel the asynchronous I/O task.

Whether a given I/O task is actually cancellable is implementation-defined. Note that due to limitations in the Win32 API, on Windows versions prior to Vista this call will cancel all pending asynchronous I/O operations for the stream associated with this task.

Exceptions:
IOException If the task could not be cancelled.
size_t getBytesTransferred (  )  throw ()

Get the number of bytes transferred by the I/O task.

This method should only be called after it has been determined that the task has completed via a call to isCompleted().

Returns:
The number of bytes that were transferred. Returns 0 if the operation is still in progress, or if its result has not yet been collected via a call to isCompleted().
bool isCompleted (  )  throw (IOException, InterruptedException)

Determine if the asynchronous I/O task has completed (either successfully or with an error); and, if so, determine the result of the operation.

If the I/O task involved a ByteBuffer, that buffer's position is bumped by the number of bytes that were transferred.

Returns:
true if the task has completed; false if it is still in progress.
Exceptions:
IOException If an I/O error occurred during the operation.
InterruptedException If the I/O task was cancelled via a call to cancel().
void waitFor ( timespan_ms_t  timeout  )  throw (IOException, InterruptedException)

Wait for an asynchronous I/O task to complete.

Parameters:
timeout The maximum amount of time to wait, in milliseconds.
Exceptions:
TimeoutException If the operation times out.
IOException If an I/O error occurred during the operation.
InterruptedException If the I/O task was cancelled via a call to cancel().

Friends And Related Function Documentation

friend class AsyncIOPoller [friend]
friend class Stream [friend]

The documentation for this class was generated from the following files:
Generated on Sat Nov 26 16:49:08 2011 for libcommonc++ by  doxygen 1.6.3