Tcl Library Source Code


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]


transfer::copy::queue - Queued transfers

Table Of Contents


package require Tcl 8.5 9
package require snit ?1.0?
package require struct::queue ?1.4?
package require transfer::copy ?0.3?
package require transfer::copy::queue ?0.2?

transfer::copy::queue objectName outchannel ?options...?
objectName method ?arg arg ...?
objectName destroy
objectName busy
objectName pending
objectName put request


This package provides objects which serialize transfer requests for a single channel by means of a fifo queue. Accumulated requests are executed in order of entrance, with the first request reaching an idle object starting the execution in general. New requests can be added while the object is active and are defered until all requests entered before them have been completed successfully.

When a request causes a transfer error execution stops and all requests coming after it are not served. Currently this means that their completion callbacks are never triggered at all.

NOTE: Not triggering the completion callbacks of the unserved requests after an error stops the queue object is something I am not fully sure that it makes sense. It forces the user of the queue to remember the callbacks as well and run them. Because otherwise everything in the system which depends on getting a notification about the status of a request will hang in the air. I am slowly convincing myself that it is more sensible to trigger the relevant completion callbacks with an error message about the queue abort, and 0 bytes transfered.

All transfer requests are of the form

{type data options...}

where type is in {chan, string}, and data specifies the information to transfer. For chan the data is the handle of the channel containing the actual information to transfer, whereas for string data contains directly the information to transfer. The options are a list of them and their values, and are the same as are accepted by the low-level copy operations of the package transfer::copy. Note how just prepending the request with transfer::copy::do and inserting a channel handle in between data and options easily transforms it from a pure data structure into a command whose evaluation will perform the request.


Package commands

Object command

All objects created by the ::transfer::copy::queue command have the following general form:

Object methods


The only option known is -on-status-change. It is optional and defaults to the empty list, disabling the reporting of status changes. Otherwise its argument is a command prefix which is invoked whenever the internal status of the object changed. The callback is invoked with two additional arguments, the result of the methods pending and busy, in this order. This allows any user to easily know, for example, when the object has processed all outstanding requests.


A possible application of this package and class is within a HTTP 1.1 server, managing the results waiting for transfer to the client.

It should be noted that in this application the system also needs an additional data structure which keeps track of outstanding results as they may come back in a different order than the requests from the client, and releases them to the actual queue in the proper order.

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category transfer of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.


channel, copy, queue, transfer


Transfer module


Copyright © 2006 Andreas Kupries