core.async

String representation for channels

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code

Description

When working with channels, I frequently have no idea what's inside it and who's blocking on it.

This simple patch shows the number of items in the buffer, as well as the number of putters and takers.

Activity

Hide
Timothy Baldridge added a comment -

It should be noted that this patch simply adds .toString to the channel type. It does not provide extra members such as count-takers, or count-putters. I would have serious problems with the latter, but simply adding .toString seems very much in line with what we already have for atoms. The output of .toString can be out of date the moment the function is executed, but since it's only really useful for debugging anyways, I don't think we care.

Show
Timothy Baldridge added a comment - It should be noted that this patch simply adds .toString to the channel type. It does not provide extra members such as count-takers, or count-putters. I would have serious problems with the latter, but simply adding .toString seems very much in line with what we already have for atoms. The output of .toString can be out of date the moment the function is executed, but since it's only really useful for debugging anyways, I don't think we care.
Hide
Timothy Baldridge added a comment -

As the docs for LinkedList notes, these structures are not thread-safe (hence all the locking done in put/take).

http://docs.oracle.com/javase/6/docs/api/java/util/LinkedList.html

So this patch runs the danger of something going really wrong.

Show
Timothy Baldridge added a comment - As the docs for LinkedList notes, these structures are not thread-safe (hence all the locking done in put/take). http://docs.oracle.com/javase/6/docs/api/java/util/LinkedList.html So this patch runs the danger of something going really wrong.
Hide
Pepijn de Vos added a comment -

What could go wrong? Count is not a structural modification, right? Or can you corrupt a list by merely taking its count while someone else is adding a thing?

If the general idea of a readable toString method sounds good, I'd be happy to add locking if necessary.

Show
Pepijn de Vos added a comment - What could go wrong? Count is not a structural modification, right? Or can you corrupt a list by merely taking its count while someone else is adding a thing? If the general idea of a readable toString method sounds good, I'd be happy to add locking if necessary.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: