Clojure

Make print-sequential interruptible

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4, Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code
  • Approval:
    Triaged

Description

This allows print-sequential to be interrupted by Thread.interrupt(), rather than requiring clients to resort to Thread.stop(). This is especially helpful when printing very large sequences.

See also clojure-dev discussion at https://groups.google.com/d/topic/clojure-dev/vs0RNUQXiYE/discussion

Patch: clj-1073-add-print-interruptibly-patch-v2.txt

Approach:

Add a new var print-interruptibly, similar to print-length, print-dup, etc. Its default is false. When true, (Thread/interrupted) is checked for after printing each element of a sequence. If true, the writer is flushed and an InterruptedIOException is thrown.

An alternative patch proposed earlier did not include print-interruptibly, but simply always checked (Thread/interrupted) after printing each element of a sequence. Benchmark tests showed that this could slow down printing of long sequences by about 10%. The approach in the proposed patch only incurs this slowdown if print-interruptibly is true. When false, there is no significant slowdown measured in benchmarks.

  1. 0001-Allow-thread-interruption-in-print-sequential.patch
    21/Sep/12 4:10 PM
    1 kB
    Colin Jones
  2. clj-1073-add-print-interruptibly-patch-v2.txt
    13/Feb/13 12:28 AM
    4 kB
    Andy Fingerhut
  3. perftest-print.clj
    21/Sep/12 7:05 PM
    0.3 kB
    Andy Fingerhut
  4. test.sh
    21/Sep/12 7:05 PM
    0.3 kB
    Andy Fingerhut

Activity

Andy Fingerhut made changes -
Field Original Value New Value
Attachment test.sh [ 11518 ]
Andy Fingerhut made changes -
Attachment perftest-print.clj [ 11519 ]
Andy Fingerhut made changes -
Attachment clj-1073-allow-thread-interrupt-in-print-sequential-patch.txt [ 11522 ]
Andy Fingerhut made changes -
Attachment clj-1073-add-print-interruptibly-patch-v1.txt [ 11667 ]
Andy Fingerhut made changes -
Attachment clj-1073-allow-thread-interrupt-in-print-sequential-patch.txt [ 11522 ]
Timothy Baldridge made changes -
Assignee Timothy Baldridge [ halgari ]
Timothy Baldridge made changes -
Approval Vetted [ 10003 ]
Assignee Timothy Baldridge [ halgari ]
Andy Fingerhut made changes -
Andy Fingerhut made changes -
Attachment clj-1073-add-print-interruptibly-patch-v1.txt [ 11667 ]
Stuart Halloway made changes -
Issue Type Defect [ 1 ] Enhancement [ 4 ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Triaged [ 10120 ]
Andy Fingerhut made changes -
Description This allows print-sequential to be interrupted by Thread.interrupt(), rather than requiring clients to resort to Thread.stop(). This is especially helpful when printing very large sequences.

See also clojure-dev discussion at https://groups.google.com/d/topic/clojure-dev/vs0RNUQXiYE/discussion
This allows print-sequential to be interrupted by Thread.interrupt(), rather than requiring clients to resort to Thread.stop(). This is especially helpful when printing very large sequences.

See also clojure-dev discussion at https://groups.google.com/d/topic/clojure-dev/vs0RNUQXiYE/discussion

*Patch:* clj-1073-add-print-interruptibly-patch-v2.txt

*Approach:*

Add a new var {{*print-interruptibly*}}, similar to {{*print-length*}}, {{*print-dup*}}, etc. Its default is false. When true, (Thread/interrupted) is checked for after printing each element of a sequence. If true, the writer is flushed and an InterruptedIOException is thrown.

An alternative patch proposed earlier did not include {{*print-interruptibly*}}, but simply always checked (Thread/interrupted) after printing each element of a sequence. Benchmark tests showed that this could slow down printing of long sequences by about 10%. The approach in the proposed patch only incurs this slowdown if {{*print-interruptibly*}} is true. When false, there is no significant slowdown measured in benchmarks.
Affects Version/s Release 1.5 [ 10150 ]
Labels patch
Andy Fingerhut made changes -
Description This allows print-sequential to be interrupted by Thread.interrupt(), rather than requiring clients to resort to Thread.stop(). This is especially helpful when printing very large sequences.

See also clojure-dev discussion at https://groups.google.com/d/topic/clojure-dev/vs0RNUQXiYE/discussion

*Patch:* clj-1073-add-print-interruptibly-patch-v2.txt

*Approach:*

Add a new var {{*print-interruptibly*}}, similar to {{*print-length*}}, {{*print-dup*}}, etc. Its default is false. When true, (Thread/interrupted) is checked for after printing each element of a sequence. If true, the writer is flushed and an InterruptedIOException is thrown.

An alternative patch proposed earlier did not include {{*print-interruptibly*}}, but simply always checked (Thread/interrupted) after printing each element of a sequence. Benchmark tests showed that this could slow down printing of long sequences by about 10%. The approach in the proposed patch only incurs this slowdown if {{*print-interruptibly*}} is true. When false, there is no significant slowdown measured in benchmarks.
This allows print-sequential to be interrupted by Thread.interrupt(), rather than requiring clients to resort to Thread.stop(). This is especially helpful when printing very large sequences.

See also clojure-dev discussion at https://groups.google.com/d/topic/clojure-dev/vs0RNUQXiYE/discussion

*Patch:* clj-1073-add-print-interruptibly-patch-v2.txt

*Approach:*

Add a new var *print-interruptibly*, similar to *print-length*, *print-dup*, etc. Its default is false. When true, (Thread/interrupted) is checked for after printing each element of a sequence. If true, the writer is flushed and an InterruptedIOException is thrown.

An alternative patch proposed earlier did not include *print-interruptibly*, but simply always checked (Thread/interrupted) after printing each element of a sequence. Benchmark tests showed that this could slow down printing of long sequences by about 10%. The approach in the proposed patch only incurs this slowdown if *print-interruptibly* is true. When false, there is no significant slowdown measured in benchmarks.
Alex Miller made changes -
Labels print

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated: