Page 184 - DCAP507_SYSTEM_SOFTWARE
P. 184

System Software




                    Notes          asio_handler_deallocate(pointer,  size,  &this_handler->handler_);
                                   }
                                   template<class  F,  class  ReadHandler>

                                   void  handler_invoke(const  F&  f,
                                    bound_read_handler<ReadHandler>*  this_handler)
                                   {
                                     using  namespace  boost::asio;

                                   handler_invoke(f,  &this_handler->handler_);
                                   }
                                   If the thread that begins an asynchronous operation finishes before the related handler is invoked,
                                   the  behaviour is implementation-defined. Particularly,  onWindows versions  prior to Vista,
                                   unfinished operations are cancelled when the initiating thread exits.
                                   The handler argument to an initiating function defines a handler identity. Specifically, the original
                                   handler argument and any copies of the handler argument will be measured equivalent. If the
                                   implementation requires to allocate storage for an asynchronous operation, the execution will
                                   perform  asio_handler_allocate(size, &h), where size is the required size in bytes, and h is the
                                   handler. The execution will carry out  asio_handler_deallocate(p, size, &h), where p is a pointer to
                                   the storage, to deallocate the storage before the invocation of the handler via  asio_handler_invoke.
                                   Numerous storage blocks may be assigned for a single asynchronous operation.




                                      Task  Illustrate the arguments to initiating functions.

                                   Self Assessment

                                   Fill in the blanks:
                                   6.  The .............................  class offers the BeginRead and EndRead methods to asynchronously
                                       read bytes from a file.
                                   7.  For every call to BeginOperationName, the application should also call .............................
                                       to obtain the results of the operation.
                                   8.  The BeginOperationName method starts asynchronous  operation OperationName and
                                       returns an object that executes the ............................. interface.

                                   9.  If the BeginOperationNamemethod throws exceptions, the ............................. method is not
                                       invoked.
                                   10.  An asynchronous operation is initiated by a function that is named with the prefix async_.
                                       These functions will be pointed to as ..............................
                                   11.  A ............................. handler  is a handler object that includes a copy of a user-supplied
                                       handler, where the user-supplied handler accepts one or more arguments.











          178                               LOVELY PROFESSIONAL UNIVERSITY
   179   180   181   182   183   184   185   186   187   188   189