render_remote.h
changeset 7 446c0b816b91
parent 6 4252c27f2b72
child 8 4d38ccbeb93e
equal deleted inserted replaced
6:4252c27f2b72 7:446c0b816b91
    20  *
    20  *
    21  * The various callback functions must all be provided.
    21  * The various callback functions must all be provided.
    22  *
    22  *
    23  * cb_sent will be invoked after the request has succesfully been written, and before cb_data is called.
    23  * cb_sent will be invoked after the request has succesfully been written, and before cb_data is called.
    24  * cb_data is called whenever new data has been received. See also, render_remote_set_chunk_size
    24  * cb_data is called whenever new data has been received. See also, render_remote_set_chunk_size
    25  * cb_done is called when all the data has been passed to cb_data
    25  * cb_done is called after our last call to cb_data (note: see render_remote_shake)
    26  * cb_fail is called when an error is encountered. This can (and will) happen at any time!
    26  * cb_fail is called when an error is encountered. This can (and will) happen at any time!
    27  */
    27  */
    28 struct remote_render_ctx *render_remote (
    28 struct remote_render_ctx *render_remote (
    29         render_t *render_ctx,               // what to render
    29         render_t *render_ctx,               // what to render
    30         struct sockaddr_storage *remote,    // what render node to use
    30         struct sockaddr_storage *remote,    // what render node to use
    34         void (*cb_fail)(void *arg),
    34         void (*cb_fail)(void *arg),
    35         void *cb_arg;
    35         void *cb_arg;
    36 );
    36 );
    37 
    37 
    38 /*
    38 /*
    39  * Cancel the given request. No more callbacks will be called, buffered data is discarded and the remote render process will cancel asap.
    39  * Cancel the given request. No more callbacks will be called, buffered data is
       
    40  * discarded and the remote render process will cancel ASAP.
    40  */
    41  */
    41 void render_remote_cancel (struct remote_render_ctx *ctx);
    42 void render_remote_cancel (struct remote_render_ctx *ctx);
    42 
    43 
    43 /*
    44 /*
    44  * Controls the behaviour of when cb_data is called, and how remote data is read in.
    45  * Controls the behaviour of when cb_data is called, and how remote data is read in.
    45  *
    46  *
    46  * recv_threshold, sets a threshold for calling cb_data - cb_data will only be called
    47  * recv_threshold sets a threshold for calling cb_data - cb_data will only be
    47  * if the buffer contains at least recv_threshold, bytes. Note that cb_data is only
    48  * called if the buffer contains at least recv_threshold bytes. Note that
    48  * ever called when new data has been receieved from the remote end - never
    49  * cb_data is only called once new data has been receieved from the remote end.
    49  * otherwise. If cb_data doesn't drain the buffer, cb_data will be called again
    50  * If cb_data doesn't drain the buffer, cb_data will be called again once more
    50  * once more data has been received from the remote end.
    51  * data has been received from the remote end.
    51  *
    52  *
    52  * overflow_size can be used to control the amount of unread data in cb_data. If 
    53  * unread_buffer can be used to control the amount of unread data in cb_data.
    53  * the buffer contains more than recv_threshold + unread_buffer bytes, we will stop
    54  * If the buffer contains more than recv_threshold + unread_buffer bytes, we
    54  * accepting bytes from the remote end, and cb_data will not be called any more.
    55  * will stop accepting bytes from the remote end, and cb_data will not be
       
    56  * called any more.
       
    57  *
       
    58  * This means that there is a potential for deadlock if the buffer is full. You
       
    59  * MUST call render_remote_shake once you are ready to start consuming the
       
    60  * buffer again.
    55  *
    61  *
    56  * Only call this once cb_sent has fired
    62  * Only call this once cb_sent has fired
    57  */
    63  */
    58 int render_remote_set_recv (struct remote_render_ctx *ctx, size_t recv_threshold, size_t unread_buffer);
    64 int render_remote_set_recv (struct remote_render_ctx *ctx, size_t recv_threshold, size_t unread_buffer);
    59 
    65