Skip to content

Commit 8be3121

Browse files
author
jan.nijtmans
committed
TIP #590: Make "thread" available as lower-case package name too
1 parent fe0c001 commit 8be3121

13 files changed

+37
-23
lines changed

doc/thread.man

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[moddesc {Tcl Threading}]
44
[titledesc {Extension for script access to Tcl threading}]
55
[require Tcl 8.5]
6-
[require Thread [opt 2.8]]
6+
[require thread [opt 2.8]]
77

88
[description]
99
The [package thread] extension creates threads that contain Tcl

doc/tpool.man

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[moddesc {Tcl Threading}]
44
[titledesc {Part of the Tcl threading extension implementing pools of worker threads.}]
55
[require Tcl 8.5]
6-
[require Thread [opt 2.8]]
6+
[require thread [opt 2.8]]
77

88
[description]
99
This package creates and manages pools of worker threads. It allows you

doc/tsv.man

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[moddesc {Tcl Threading}]
44
[titledesc {Part of the Tcl threading extension allowing script level manipulation of data shared between threads.}]
55
[require Tcl 8.5]
6-
[require Thread [opt 2.8]]
6+
[require thread [opt 2.8]]
77

88
[description]
99
This section describes commands implementing thread shared variables.

doc/ttrace.man

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[moddesc {Tcl Threading}]
44
[titledesc {Trace-based interpreter initialization}]
55
[require Tcl 8.5]
6-
[require Thread [opt 2.8]]
6+
[require thread [opt 2.8]]
77

88
[description]
99
This package creates a framework for on-demand replication of the
@@ -20,17 +20,17 @@ with the Tcl threading extension:
2020

2121
[example {
2222

23-
% package require Ttrace
24-
2.8.2
23+
% package require ttrace
24+
2.9.0
2525

26-
% set t1 [thread::create {package require Ttrace; thread::wait}]
26+
% set t1 [thread::create {package require ttrace; thread::wait}]
2727
tid0x1802800
2828

2929
% ttrace::eval {proc test args {return test-[thread::id]}}
3030
% thread::send $t1 test
3131
test-tid0x1802800
3232

33-
% set t2 [thread::create {package require Ttrace; thread::wait}]
33+
% set t2 [thread::create {package require ttrace; thread::wait}]
3434
tid0x1804000
3535

3636
% thread::send $t2 test

generic/threadCmd.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ Thread_Init(
540540
return status;
541541
}
542542

543-
return Tcl_PkgProvideEx(interp, "Thread", PACKAGE_VERSION, NULL);
543+
Tcl_PkgProvideEx(interp, "Thread", PACKAGE_VERSION, NULL);
544+
return Tcl_PkgProvideEx(interp, "thread", PACKAGE_VERSION, NULL);
544545
}
545546

546547
/*

lib/ttrace.tcl

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace eval ttrace {
7373
}
7474

7575
# Keep in sync with the Thread package
76+
package provide ttrace 2.9a1
7677
package provide Ttrace 2.9a1
7778

7879
# Package variables
@@ -116,7 +117,7 @@ namespace eval ttrace {
116117
ns_ictl save [getscript]
117118
} else {
118119
thread::broadcast {
119-
package require Ttrace
120+
package require ttrace
120121
ttrace::update
121122
}
122123
}

pkgIndex.tcl.in

+18-6
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,36 @@ if {![package vsatisfies [package provide Tcl] 8.5]} {
1111
}
1212
}
1313

14-
# All Tcl 8.5+ interps can [load] Thread @PACKAGE_VERSION@
14+
# All Tcl 8.5+ interps can [load] thread @PACKAGE_VERSION@
1515
#
1616
# For interps that are not thread-enabled, we still call [package ifneeded].
1717
# This is contrary to the usual convention, but is a good idea because we
1818
# cannot imagine any other version of Thread that might succeed in a
1919
# thread-disabled interp. There's nothing to gain by yielding to other
20-
# competing callers of [package ifneeded Thread]. On the other hand,
20+
# competing callers of [package ifneeded thread]. On the other hand,
2121
# deferring the error has the advantage that a script calling
22-
# [package require Thread] in a thread-disabled interp gets an error message
22+
# [package require thread] in a thread-disabled interp gets an error message
2323
# about a thread-disabled interp, instead of the message
2424
# "can't find package Thread".
2525

26-
package ifneeded Thread @PACKAGE_VERSION@ [list load [file join $dir @PKG_LIB_FILE@] [string totitle @PACKAGE_NAME@]]
26+
package ifneeded [string tolower @PACKAGE_NAME@] @PACKAGE_VERSION@ [list load [file join $dir @PKG_LIB_FILE@] [string totitle @PACKAGE_NAME@]]
27+
package ifneeded [string totitle @PACKAGE_NAME@] @PACKAGE_VERSION@ [list load [file join $dir @PKG_LIB_FILE@] [string totitle @PACKAGE_NAME@]]
2728

2829
# package Ttrace uses some support machinery.
2930

30-
# In Tcl 8.5+ interps; use [::apply]
31-
31+
package ifneeded ttrace @PACKAGE_VERSION@ [list ::apply {{dir} {
32+
if {[info exists ::env(TCL_THREAD_LIBRARY)] &&
33+
[file readable $::env(TCL_THREAD_LIBRARY)/ttrace.tcl]} {
34+
source $::env(TCL_THREAD_LIBRARY)/ttrace.tcl
35+
} elseif {[file readable [file join $dir .. lib ttrace.tcl]]} {
36+
source [file join $dir .. lib ttrace.tcl]
37+
} elseif {[file readable [file join $dir ttrace.tcl]]} {
38+
source [file join $dir ttrace.tcl]
39+
}
40+
if {[namespace which ::ttrace::update] ne ""} {
41+
::ttrace::update
42+
}
43+
}} $dir]
3244
package ifneeded Ttrace @PACKAGE_VERSION@ [list ::apply {{dir} {
3345
if {[info exists ::env(TCL_THREAD_LIBRARY)] &&
3446
[file readable $::env(TCL_THREAD_LIBRARY)/ttrace.tcl]} {

tests/all.tcl

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
package require tcltest
1111
::tcltest::loadTestedCommands
12-
package require Thread
12+
package require -exact thread 2.9a1
1313

1414
set ::tcltest::testSingleFile false
1515
set ::tcltest::testsDirectory [file dir [info script]]
@@ -39,7 +39,7 @@ puts stdout "Tests began at [eval $timeCmd]"
3939
# These tests need to know which is the main thread
4040
set ::tcltest::mainThread [thread::id]
4141

42-
puts stdout "Thread [package provide Thread]"
42+
puts stdout "thread [package provide thread]"
4343
puts stdout "Mainthread id is $::tcltest::mainThread"
4444

4545
# Source each of the specified tests

tests/store-load.tcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env tclsh
22

33
lappend auto_path .
4-
package require Thread
4+
package require thread
55

66
if {[llength $argv] != 3} {
77
puts "Usage: $argv0 handle path times"

tests/thread.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package require tcltest
1515
namespace import ::tcltest::*
1616
tcltest::loadTestedCommands
17-
package require Thread
17+
package require thread
1818

1919
tcltest::testConstraint chanTransfer \
2020
[expr {$::tcl_platform(platform) == "unix"}]

tests/tkt-84be1b5a73.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package require tcltest
22
namespace import ::tcltest::*
33
tcltest::loadTestedCommands
4-
package require Thread
4+
package require thread
55

66
# This test used to segfault before commit f4c95731c0.
77
test tkt-84be1b5a73 {Ticket 84be1b5a73} -body {

tests/tsv.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package require tcltest
22
namespace import ::tcltest::*
33
tcltest::loadTestedCommands
4-
package require Thread
4+
package require thread
55

66
set backends {gdbm lmdb}
77

unix/CONFIG

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
# --prefix=$nsdir --exec-prefix=$nsdir
3939
#
4040
# NaviServer/AOLserver uses its own package loading mechanism.
41-
# To load, just do "ns_eval package require Thread"
41+
# To load, just do "ns_eval package require thread"
4242
# at the NaviServer/AOLserver startup or later from any thread.
4343
#
4444
#

0 commit comments

Comments
 (0)