Skip to content

Commit 12c36d7

Browse files
ranjananstevengj
authored andcommitted
Add threadid() and nthreads() (#240)
* Add `threadid()` and `nthreads()` * Fix `const` in definition * Fix condition in test * Remove condition and modify test * Fix bug in export
1 parent 8e815ff commit 12c36d7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Compat.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,9 @@ if !isdefined(Base, :Threads)
10781078
macro threads(expr)
10791079
return esc(expr)
10801080
end
1081-
export @threads
1081+
threadid() = 1
1082+
nthreads() = 1
1083+
export @threads, threadid, nthreads
10821084
end
10831085
export Threads
10841086
end
@@ -1281,7 +1283,7 @@ else
12811283
end
12821284

12831285
if !isdefined(Base, :view)
1284-
const view = slice
1286+
const view = slice
12851287
end
12861288

12871289
if !isdefined(Base, :pointer_to_string)

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,9 @@ using Compat.Threads
11471147
@test true
11481148
end
11491149

1150+
# Issue #223
1151+
@test 1 == threadid() <= nthreads()
1152+
11501153
@test @compat(Symbol("foo")) === :foo
11511154
@test @compat(Symbol("foo", "bar")) === :foobar
11521155
@test @compat(Symbol("a_", 2)) === :a_2

0 commit comments

Comments
 (0)