Ignore:
Timestamp:
Nov 15, 2011 11:56:51 AM (12 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/packages/vizservers/vtkvis/ResponseQueue.h

    r2543 r2681  
    1717namespace VtkVis {
    1818
     19/**
     20 * \brief Holds data for a response to be sent to client
     21 */
    1922class Response
    2023{
     
    4043    virtual ~Response()
    4144    {
    42         if (_length > 0) {
    43             if (_allocType == DYNAMIC) {
    44                 free(_mesg);
    45             }
     45        if ((_length > 0) && (_mesg != NULL) && (_allocType == DYNAMIC)) {
     46            free(_mesg);
    4647        }
    4748    }
    4849
     50    /// Get the ResponseType
    4951    ResponseType type()
    5052    {
     
    5254    }
    5355
     56    /// Get the Response data
    5457    unsigned char *message()
    5558    {
     
    5760    }
    5861
     62    /// Get the number of bytes in the Response data
    5963    size_t length()
    6064    {
     
    6266    }
    6367
     68    /// Set the message/data making up the Response
     69    /**
     70     * If the AllocationType is DYNAMIC, the message data will be free()d
     71     * by the destructor.  If the AllocationType is VOLATILE, a copy of
     72     * the message data will be made.
     73     *
     74     * \param[in] mesg The Response data, can be a command and/or binary data
     75     * \param[in] length The number of bytes in mesg
     76     * \param[in] type Specify how the memory was allocated for mesg
     77     */
    6478    void setMessage(unsigned char *mesg, size_t length, AllocationType type)
    6579    {
     
    86100};
    87101
     102/**
     103 * \brief Queue to hold pending Responses to be sent to the client
     104 *
     105 * A semaphore and mutex are used to control access to the
     106 * queue by a reader and writer thread
     107 */
    88108class ResponseQueue
    89109{
     
    93113    virtual ~ResponseQueue();
    94114
     115    /// A place to store a data pointer.  Not used internally.
     116    /* XXX: This probably doesn't belong here */
    95117    void *clientData()
    96118    {
     
    98120    }
    99121
     122    /// Add a response to the end of the queue
    100123    void enqueue(Response *response);
    101124
     125    /// Remove a response from the front of the queue
    102126    Response *dequeue();
    103127
Note: See TracChangeset for help on using the changeset viewer.