[racket] Test for async-channel being full

From: Eric Dobson (eric.n.dobson at gmail.com)
Date: Tue Dec 3 12:49:08 EST 2013

I just ended up using a pipe and having my other thread read from that
in addition to other inputs, as custom output ports are too much of a
pain to actually use.

I lost ordering of events, (i.e. cannot tell whether output to the
pipe came before or after a message on another channel), but was able
to mostly hack around that.


On Tue, Dec 3, 2013 at 5:44 AM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> Oh, right: so you probably don't want 'get' 'put' and 'is-full?' but you
> want 'get' and 'try-put' that fails only when the channel is full, returning
> a boolean to indicate success.
>
> Robby
>
>
> On Mon, Dec 2, 2013 at 11:24 PM, David T. Pierson <dtp at mindstory.com> wrote:
>>
>> On Fri, Nov 29, 2013 at 12:23:42PM -0800, Eric Dobson wrote:
>> > I'm trying to make a custom output port that is backed by a
>> > async-channel. One of the operations that ports need to provide is an
>> > event that is ready when progress on the event can be made. But since
>> > I cannot tell if the async-channel is full and put would not block
>> > without actually sending a value, I cannot provide such an event. Is
>> > it possible to provide such an API or does the implementation of
>> > async-channels prevent this?
>>
>> I don't know much about creating custom ports, so I looked up progress
>> events in order to understand your question better.  But now I'm
>> confused, because progress events seem to be specific to input ports,
>> whereas it sounds like you are creating an output port.  What am I
>> missing?
>>
>> Regarding your actual question: I think the reason a non-side-effecting
>> async-channel-put-evt is not provided is that using such an event could
>> lead to race conditions.  A previous thread [1] on this list touched on
>> this with regard to places and channels as events; I'm extrapolating to
>> extend that answer to async-channel-put-evt.
>>
>> David
>>
>> [1] http://www.mail-archive.com/users@racket-lang.org/msg15630.html
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>
>

Posted on the users mailing list.