Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports for 1.2-RC1 #31727

Closed
wants to merge 71 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
10a843f
add a missing `free` in subtyping (#31668)
JeffBezanson Apr 11, 2019
f3e5612
fix #31496, type intersection bug in restoring environment (#31669)
JeffBezanson Apr 11, 2019
5c61d3a
dispatch: fix incorrect signature narrowing for U{Type, S} (#31671)
vtjnash Apr 11, 2019
95e2a54
channels: remove WeakRef from Condition (#31673)
vtjnash Apr 11, 2019
414b46d
edit 1.2 release notes (#31692)
JeffBezanson Apr 11, 2019
4a6b3c5
fix #31686, segfault on invalid cmdline option (#31689)
JeffBezanson Apr 11, 2019
e3150fc
Fix doctest from utf8proc update. (#31688)
fredrikekre Apr 12, 2019
05993a4
Upgrade Pkg to 1.2.0-rc1. (#31679)
fredrikekre Apr 12, 2019
0e5e1ea
fix a missing GC root in type intersection (#31708)
JeffBezanson Apr 12, 2019
a28450d
fix #31702, thread sitting in event loop outside thread region (#31709)
JeffBezanson Apr 13, 2019
21fc367
make aliasscope more resilient to missing push
vchuravy Mar 26, 2019
eb5059b
Fix regressed compilation of uncached code.
maleadt Apr 11, 2019
568e920
fix #31663, long inference time printing large tree structure (#31680)
JeffBezanson Apr 16, 2019
9d41ffc
Bump Pkg to 1.2.0-alpha.2. (#31749)
fredrikekre Apr 18, 2019
dd32213
inference: fix fieldtype tfunc design (#31670)
vtjnash Apr 18, 2019
e1d23bc
fix #31703, type intersection bug with chains of vars in invariant po…
JeffBezanson Apr 18, 2019
9115c82
fix #31760, regression in Dict `iterate` (#31762)
JeffBezanson Apr 18, 2019
2534ac5
inference: accelerate type-limits under wide-recursion (#31734)
vtjnash Apr 19, 2019
b0187e8
fix #31758: out of bounds write in sparse broadcast (#31763)
fredrikekre Apr 19, 2019
3d42798
Upgrade `libssh2` version to `1.8.2`
staticfloat Apr 17, 2019
28f483c
Update `refresh_bb_tarballs.sh` now that `compile-*` doesn't checksum
staticfloat Apr 17, 2019
c33075c
inf or nan parsing should ignore leading spaces
stevengj Apr 12, 2019
9289be5
fix parse(ComplexF64, "inf")
stevengj Apr 4, 2019
580d2f8
Simplify llvm.dbg.declare for pointer arguments.
maleadt Apr 11, 2019
9501bd2
Always check for illegal stores now that arguments are handled.
maleadt Apr 11, 2019
300e739
Fix issue 31252 - remote globals not being updated in some cases
amitmurthy Mar 22, 2019
eae30d6
precompile: permit saving code (regression) (#31773)
vtjnash Apr 22, 2019
6d01613
more fixes to I/O and threading (#31733)
JeffBezanson Apr 22, 2019
68fc64a
fix droptol! docstrings (#31799)
dkarrasch Apr 23, 2019
7d0baab
Improve IO read performance. (#31814)
tkoolen Apr 24, 2019
c3dc4ce
fix incorrect error path in `schedule` (#31812)
JeffBezanson Apr 24, 2019
b6494e3
fix #31803, covariance handling in `fieldtype_tfunc` (#31848)
JeffBezanson Apr 28, 2019
a4d5aa1
Recover meta nodes in replace_code_newstyle (#31871)
nlw0 Apr 30, 2019
3ba3cb8
Ensure syntax error locations appear in backtraces (#31881)
c42f May 2, 2019
a1266e0
improve compilation of check_top_bit (#31883)
vtjnash May 3, 2019
695c3ac
Revert "Don't use jl_rethrow_other for LoadError/InitError" (#31963)
c42f May 8, 2019
7c09900
always run on original process stack in ALWAYS_COPY_STACKS mode (#31697)
JeffBezanson May 8, 2019
339911f
fix #31965, bug in interpreter stacktraces and `jl_code_requires_comp…
JeffBezanson May 9, 2019
1d7c1fa
Revert "Fix `repr` on `Period` Types, and `DateTime`, `Date` (#30817)"
KristofferC May 10, 2019
37dbfc1
Revert "Fix `repr` on `DateTime` (#30200)"
KristofferC May 10, 2019
cce06d6
Fix world age issues in Serialization test if run in Main (#31973)
Keno May 9, 2019
2c2b344
Fix pop_exception lowering for try-break-finally (#31766) (#31931)
c42f May 9, 2019
508ce89
Accept both Cvoid and Ptr{Void} return type in ccall(:memcpy) (#31464)
Keno May 10, 2019
3a0e1d0
synchronize FileWatching (#31981)
JeffBezanson May 10, 2019
413901f
Don't attempt to const prop call cycles (#31996)
Keno May 11, 2019
8653aed
fix #31899, type intersection involving Int in upper bound (#31960)
JeffBezanson May 8, 2019
e3de220
fix #31993, intersection of `Type{Vec}` and `Type{<:Vec{T}}` (#31997)
JeffBezanson May 11, 2019
dac41b4
Change BB tarball naming scheme to include release number (#32025)
staticfloat May 15, 2019
4574af8
fix potential stack overflow in Profile.jl (#31693)
JeffBezanson Apr 12, 2019
9fa5ea8
Prevent stack overflow in Profile (#31893)
Keno May 2, 2019
3715384
bugfix in Hermitian + complex*I (#32001)
stevengj May 14, 2019
84ca0c0
Update Mozilla CA certificate store to latest (05-15-2019) for libgit…
mikhail-j May 15, 2019
fcc28a7
restore previous exports from Base.Threads (#32036)
JeffBezanson May 16, 2019
a89634b
fix serializer for compat with 1.0 for saved functions (#32028)
JeffBezanson May 16, 2019
291109b
fix `isa` fast path for typevars with lower bounds (#32040)
JeffBezanson May 16, 2019
efcc509
move export of `Event` from Base back to Threads (#32043)
JeffBezanson May 16, 2019
13bcc06
fix #32046, Error test result from test_logs (#32052)
JeffBezanson May 16, 2019
f254c2e
Add Base64 to Serialization test deps (#32053)
Keno May 16, 2019
861f7a2
fix #31674, error when storing nonzeros into structural zeros with .=…
mbauman May 16, 2019
b19fcbc
Disable BB `GMP` and `MPFR`, to fix performance regressions (#32102)
staticfloat May 22, 2019
1b72e97
Prevent the GC task callback from segfaulting. (#32088)
rbehrends May 20, 2019
ae8fc04
BunchKauffman: correct permutation for rook pivoting (fixes #32080) (…
timholy May 22, 2019
b4ff156
put back broadcast behavior with repeated indices, changed by #31300 …
JeffBezanson May 23, 2019
ad5e60a
work around #32087 by polling for I/O on windows inside thread loops …
JeffBezanson May 23, 2019
e5dfde8
Amend matrix * vector specialization for strided arrays (#32097)
ararslan May 23, 2019
5180ffe
Automatically disable `USE_BINARYBUILDER_xxx` when `USE_SYSTEM_xxx` i…
staticfloat May 23, 2019
52e9e4c
Fix BB backport definition
staticfloat May 23, 2019
d85d093
add missing testhelpers/llvmpasses.jl file (#32175)
JeffBezanson May 29, 2019
e6280f5
fix license headers and a doc link
JeffBezanson May 29, 2019
754605d
Set VERSION to 1.2.0-rc1
JeffBezanson May 29, 2019
84854b1
Add GCC 9 support to `normalize_triplet.py` (#31976)
staticfloat May 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ before_install:
ln -s /usr/bin/g++-5 $HOME/bin/x86_64-linux-gnu-g++;
gcc --version;
BAR="bar -i 30";
BUILDOPTS="-j5 VERBOSE=1 FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1 USECCACHE=1 USE_BINARYBUILDER_LIBUV=0 USE_BINARYBUILDER_UNWIND=0 USE_BINARYBUILDER_LLVM=0";
BUILDOPTS="-j5 VERBOSE=1 FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1 USECCACHE=1 USE_BINARYBUILDER_LIBUV=0 USE_BINARYBUILDER_LIBUNWIND=0 USE_BINARYBUILDER_LLVM=0";
echo "override ARCH=$ARCH" >> Make.user;
sudo sh -c "echo 0 > /proc/sys/net/ipv6/conf/lo/disable_ipv6";
export JULIA_CPU_THREADS=4;
Expand Down
38 changes: 35 additions & 3 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# Set to zero to turn off extra precompile (e.g. for the REPL)
JULIA_PRECOMPILE ?= 1

FORCE_ASSERTIONS ?= 0

# OPENBLAS build options
OPENBLAS_TARGET_ARCH:=
OPENBLAS_SYMBOLSUFFIX:=
Expand Down Expand Up @@ -927,7 +929,7 @@ else
endif

# BinaryBuilder options. We default to "on" for all the projects listed in BB_PROJECTS,
# but only if contrib/normalize_triplet.py works for our requested triplet
# but only if contrib/normalize_triplet.py works for our requested triplet.
ifeq ($(shell python $(JULIAHOME)/contrib/normalize_triplet.py $(or $(XC_HOST),$(XC_HOST),$(BUILD_MACHINE)) >/dev/null 2>/dev/null; echo $$?),0)
USE_BINARYBUILDER := 1
else
Expand All @@ -937,9 +939,39 @@ endif
USE_BINARYBUILDER := 0
endif

# GMP and MPFR have serious performance regressions for now
USE_BINARYBUILDER_GMP ?= 0
USE_BINARYBUILDER_MPFR ?= 0

# This is the set of projects that BinaryBuilder dependencies are hooked up for.
BB_PROJECTS := OPENBLAS LLVM SUITESPARSE OPENLIBM GMP MBEDTLS LIBSSH2 MPFR CURL LIBGIT2 PCRE LIBUV UNWIND
$(foreach proj,$(BB_PROJECTS),$(if $(USE_BINARYBUILDER_$(proj)),,$(eval USE_BINARYBUILDER_$(proj) := $(USE_BINARYBUILDER))))
BB_PROJECTS := OPENBLAS LLVM SUITESPARSE OPENLIBM MBEDTLS LIBSSH2 CURL LIBGIT2 PCRE LIBUV UNWIND
define SET_BB_DEFAULT
# First, check to see if BB is disabled on a global setting
ifeq ($$(USE_BINARYBUILDER),0)
USE_BINARYBUILDER_$(1) ?= 0
else
# If it's not, check to see if it's disabled by a USE_SYSTEM_xxx flag
ifeq ($$(USE_SYSTEM_$(1)),1)
USE_BINARYBUILDER_$(1) ?= 0
else
USE_BINARYBUILDER_$(1) ?= 1
endif
endif
endef
$(foreach proj,$(BB_PROJECTS),$(eval $(call SET_BB_DEFAULT,$(proj))))

# Some special restrictions on BB usage:
ifeq ($(USE_SYSTEM_BLAS),1)
# Since the names don't line up (`BLAS` vs. `OPENBLAS`), manually gate:
USE_BINARYBUILDER_OPENBLAS ?= 0
# Disable BB SuiteSparse if we're using system BLAS
USE_BINARYBUILDER_SUITESPARSE ?= 0
endif

ifeq ($(USE_SYSTEM_LIBM),1)
# If we're using system libm, disable BB OpenLibm
USE_BINARYBUILDER_OPENLIBM ?= 0
endif

# Use the Assertions build
BINARYBUILDER_LLVM_ASSERTS := 0
Expand Down
102 changes: 44 additions & 58 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,104 +4,90 @@ Julia v1.2 Release Notes
New language features
---------------------

* Argument splatting (`x...`) can now be used in calls to the `new` pseudo-function in
constructors ([#30577]).

* Objects created by calling `skipmissing` on an array can now be indexed using indices
from the parent at non-missing positions. This allows functions such as
`findall`, `findfirst`, `argmin`/`argmax` and `findmin`/`findmax` to work with these
objects, returning the index of matching non-missing elements in the parent ([#31008]).

* `inv(::Missing)` has now been added and returns `missing` ([#31451]).
* Argument splatting (`x...`) can now be used in calls to the `new` pseudo-function in
constructors ([#30577]).
* Support for Unicode 12.0.0 ([#31561]).
* Added `⋆` (`\star`) as unary operator ([#31604]).

* `nextfloat(::BigFloat, n::Integer)` and `prevfloat(::BigFloat, n::Integer)` methods
have been added ([#31310]).
Language changes
----------------

* Support for Unicode 12.0.0 ([#31561]).
* Empty entries in `JULIA_DEPOT_PATH` are now expanded to default depot entries ([#31009]).

Multi-threading changes
-----------------------

* The `Condition` type now has a thread-safe replacement, accessed as `Threads.Condition`.
With that addition, task scheduling primitives such as `ReentrantLock` are now thread-safe ([#30061]).

* It is possible to schedule and switch Tasks during `@threads` loops, and perform limited I/O ([#31438]).

Language changes
----------------
* Empty entries in `JULIA_DEPOT_PATH` are now expanded to default depot entries ([#31009]).
* `Enum` now behaves like a scalar when used in broadcasting ([#30670]).
* If a `pipeline` is specified with `append=true` set, but no redirection, an `ArgumentError`
is thrown, rather than a `ErrorException` ([#27900]).
* Functions that invoke commands (e.g. `run(::Cmd)`) now throw a `ProcessFailedException`
rather than an `ErrorException`, if those commands exit with non-zero exit code.
([#27900]).
* Added `⋆` (`\star`) as unary operator ([#31604]).
With that addition, task scheduling primitives such as `ReentrantLock` are now thread-safe ([#30061]).
* It is possible to schedule and switch Tasks during `@threads` loops, and perform limited I/O ([#31438]).

Command-line option changes
---------------------------
Build system changes
--------------------

* The build system now prefers downloading prebuilt binary tarballs for most dependencies on
supported systems, disable by setting `USE_BINARYBUILDER=0` at `make` time ([#31441]).

New library functions
---------------------

* `getipaddrs()` function returns all the IP addresses of the local machine, with IPv4 addresses sorting before IPv6 addresses ([#30349, #30604])
* `getipaddr(addr_type)` and `getipaddrs(addr_type)` functions returns an IP address(es) of the desired type of the local machine ([#30604])
* `getipaddrs()` function returns all the IP addresses of the local machine, with IPv4 addresses sorting before IPv6 addresses ([#30349, #30604]).
* `getipaddr(addr_type)` and `getipaddrs(addr_type)` functions returns an IP address(es) of the desired type of the local machine ([#30604]).
* Added `Base.hasproperty` and `Base.hasfield` ([#28850]).
* One argument `!=(x)`, `>(x)`, `>=(x)`, `<(x)`, `<=(x)` has been added for currying,
similar to the existing `==(x)` and `isequal(x)` methods ([#30915]).
* One argument `!=(x)`, `>(x)`, `>=(x)`, `<(x)`, `<=(x)` have been added, returning partially-applied
versions of the functions, similar to the existing `==(x)` and `isequal(x)` methods ([#30915]).

Standard library changes
------------------------

* `Enum` now behaves like a scalar when used in broadcasting ([#30670]).
* If a `pipeline` is specified with `append=true` set, but no redirection, an `ArgumentError`
is thrown, rather than a `ErrorException` ([#27900]).
* Functions that invoke commands (e.g. `run(::Cmd)`) now throw a `ProcessFailedException`
rather than an `ErrorException`, if those commands exit with non-zero exit code ([#27900]).
* The `extrema` function now accepts a function argument in the same manner as `minimum` and
`maximum` ([#30323]).
* `hasmethod` can now check for matching keyword argument names ([#30712]).
* `startswith` and `endswith` now accept a `Regex` for the second argument ([#29790]).
* `retry` supports arbitrary callable objects ([#30382]).
* `filter` now supports `SkipMissing`-wrapped arrays ([#31235]).
* A no-argument construct to `Ptr{T}` has been added which constructs a null pointer ([#30919])
* `strip` now accepts a function argument in the same manner as `lstrip` and `rstrip` ([#31211])
* `mktempdir` now accepts a `prefix` keyword argument to customize the file name ([#31230], [#22922])
* A no-argument constructor for `Ptr{T}` has been added which constructs a null pointer ([#30919]).
* `strip` now accepts a function argument in the same manner as `lstrip` and `rstrip` ([#31211]).
* `mktempdir` now accepts a `prefix` keyword argument to customize the file name ([#31230], [#22922]).
* `keytype` and `valtype` now work on `AbstractArray`, and return the `eltype` of `keys(...)` and
`values(...)` respectively ([#27749]).
* `nextfloat(::BigFloat)` and `prevfloat(::BigFloat)` now returns a value with the same precision
as their argument, which means that (in particular) `nextfloat(prevfloat(x)) == x` whereas
previously this could result in a completely different value with a different precision ([#31310])
* `mapreduce` now accept multiple iterators, similar to `map` ([#31532]).
previously this could result in a completely different value with a different precision ([#31310]).
* `mapreduce` now accepts multiple iterators, similar to `map` ([#31532]).
* `filter` now supports `SkipMissing`-wrapped arrays ([#31235]).
* Objects created by calling `skipmissing` on an array can now be indexed using indices
from the parent at non-missing positions. This allows functions such as
`findall`, `findfirst`, `argmin`/`argmax` and `findmin`/`findmax` to work with these
objects, returning the index of matching non-missing elements in the parent ([#31008]).
* `inv(::Missing)` has now been added and returns `missing` ([#31451]).
* `nextfloat(::BigFloat, n::Integer)` and `prevfloat(::BigFloat, n::Integer)` methods
have been added ([#31310]).

#### LinearAlgebra

* Added keyword arguments `rtol`, `atol` to `pinv` and `nullspace` ([#29998]).
* `UniformScaling` instances are now callable such that e.g. `I(3)` will produce a `Diagonal` matrix ([#30298]).
* Eigenvalues λ of general matrices are now sorted lexicographically by (Re λ, Im λ) ([#21598]).
* `one` for structured matrices (`Diagonal`, `Bidiagonal`, `Tridiagonal`, `Symtridiagonal`) now preserves
structure and type. ([#29777])
* `diagm(v)` is now a shorthand for `diagm(0 => v)`. ([#31125]).
structure and type ([#29777]).
* `diagm(v)` is now a shorthand for `diagm(0 => v)` ([#31125]).

#### SparseArrays

* performance improvements for sparse matrix-matrix multiplication ([#30372]).
* Performance improvements for sparse matrix-matrix multiplication ([#30372]).
* Sparse vector outer products are more performant and maintain sparsity in products of the
form `kron(u, v')`, `u * v'`, and `u .* v'` where `u` and `v` are sparse vectors or column
views. ([#24980])

#### Dates

* Fixed `repr` such that it displays `DateTime` as it would be entered in Julia ([#30200]).
views ([#24980]).

#### Statistics

* `quantile` now accepts in all cases collections whose `eltype` is not a subtype of `Number` ([#30938]).

#### Miscellaneous

* Since environment variables on Windows are case-insensitive, `ENV` now converts its keys
to uppercase for display, iteration, and copying ([#30593]).

* Build system now prefers downloading prebuilt binary tarballs for most dependencies on
supported systems, disable by setting `USE_BINARYBUILDER=0` at `make` time ([#31441]).

External dependencies
---------------------

Expand All @@ -110,20 +96,17 @@ External dependencies
* MbedTLS has been updated to v2.16.0 ([#30618]).
* libunwind has been updated to v1.3.1 ([#30724]).

Deprecated or removed
---------------------


<!--- generated by NEWS-update.jl: -->
[#21598]: https://github.com/JuliaLang/julia/issues/21598
[#22922]: https://github.com/JuliaLang/julia/issues/22922
[#24980]: https://github.com/JuliaLang/julia/issues/24980
[#27749]: https://github.com/JuliaLang/julia/issues/27749
[#27900]: https://github.com/JuliaLang/julia/issues/27900
[#28850]: https://github.com/JuliaLang/julia/issues/28850
[#29777]: https://github.com/JuliaLang/julia/issues/29777
[#29790]: https://github.com/JuliaLang/julia/issues/29790
[#29998]: https://github.com/JuliaLang/julia/issues/29998
[#30061]: https://github.com/JuliaLang/julia/issues/30061
[#30200]: https://github.com/JuliaLang/julia/issues/30200
[#30298]: https://github.com/JuliaLang/julia/issues/30298
[#30323]: https://github.com/JuliaLang/julia/issues/30323
[#30372]: https://github.com/JuliaLang/julia/issues/30372
Expand All @@ -147,6 +130,9 @@ Deprecated or removed
[#31230]: https://github.com/JuliaLang/julia/issues/31230
[#31235]: https://github.com/JuliaLang/julia/issues/31235
[#31310]: https://github.com/JuliaLang/julia/issues/31310
[#31438]: https://github.com/JuliaLang/julia/issues/31438
[#31441]: https://github.com/JuliaLang/julia/issues/31441
[#31451]: https://github.com/JuliaLang/julia/issues/31451
[#31532]: https://github.com/JuliaLang/julia/issues/31532
[#31561]: https://github.com/JuliaLang/julia/issues/31561
[#31604]: https://github.com/JuliaLang/julia/issues/31604
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0-pre
1.2.0-rc1
68 changes: 48 additions & 20 deletions base/asyncevent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Use [`isopen`](@ref) to check whether it is still active.
"""
mutable struct AsyncCondition
handle::Ptr{Cvoid}
cond::Condition
cond::ThreadSynchronizer
isopen::Bool

function AsyncCondition()
this = new(Libc.malloc(_sizeof_uv_async), Condition(), true)
this = new(Libc.malloc(_sizeof_uv_async), ThreadSynchronizer(), true)
associate_julia_struct(this.handle, this)
finalizer(uvfinalize, this)
err = ccall(:uv_async_init, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}),
Expand All @@ -41,14 +41,22 @@ the async condition object itself.
function AsyncCondition(cb::Function)
async = AsyncCondition()
waiter = Task(function()
while isopen(async)
success = try
wait(async)
true
catch exc # ignore possible exception on close()
isa(exc, EOFError) || rethrow()
lock(async.cond)
try
while isopen(async)
success = try
stream_wait(async, async.cond)
true
catch exc # ignore possible exception on close()
isa(exc, EOFError) || rethrow()
finally
unlock(async.cond)
end
success && cb(async)
lock(async.cond)
end
success && cb(async)
finally
unlock(async.cond)
end
end)
# must start the task right away so that it can wait for the AsyncCondition before
Expand All @@ -71,14 +79,14 @@ to check whether a timer is still active.
"""
mutable struct Timer
handle::Ptr{Cvoid}
cond::Condition
cond::ThreadSynchronizer
isopen::Bool

function Timer(timeout::Real; interval::Real = 0.0)
timeout ≥ 0 || throw(ArgumentError("timer cannot have negative timeout of $timeout seconds"))
interval ≥ 0 || throw(ArgumentError("timer cannot have negative repeat interval of $interval seconds"))

this = new(Libc.malloc(_sizeof_uv_timer), Condition(), true)
this = new(Libc.malloc(_sizeof_uv_timer), ThreadSynchronizer(), true)
err = ccall(:uv_timer_init, Cint, (Ptr{Cvoid}, Ptr{Cvoid}), eventloop(), this)
if err != 0
#TODO: this codepath is currently not tested
Expand All @@ -102,8 +110,13 @@ unsafe_convert(::Type{Ptr{Cvoid}}, t::Timer) = t.handle
unsafe_convert(::Type{Ptr{Cvoid}}, async::AsyncCondition) = async.handle

function wait(t::Union{Timer, AsyncCondition})
isopen(t) || throw(EOFError())
stream_wait(t, t.cond)
lock(t.cond)
try
isopen(t) || throw(EOFError())
stream_wait(t, t.cond)
finally
unlock(t.cond)
end
end

isopen(t::Union{Timer, AsyncCondition}) = t.isopen
Expand All @@ -128,24 +141,39 @@ function uvfinalize(t::Union{Timer, AsyncCondition})
end

function _uv_hook_close(t::Union{Timer, AsyncCondition})
uvfinalize(t)
notify_error(t.cond, EOFError())
lock(t.cond)
try
uvfinalize(t)
notify_error(t.cond, EOFError())
finally
unlock(t.cond)
end
nothing
end

function uv_asynccb(handle::Ptr{Cvoid})
async = @handle_as handle AsyncCondition
notify(async.cond)
lock(async.cond)
try
notify(async.cond)
finally
unlock(async.cond)
end
nothing
end

function uv_timercb(handle::Ptr{Cvoid})
t = @handle_as handle Timer
if ccall(:uv_timer_get_repeat, UInt64, (Ptr{Cvoid},), t) == 0
# timer is stopped now
close(t)
lock(t.cond)
try
if ccall(:uv_timer_get_repeat, UInt64, (Ptr{Cvoid},), t) == 0
# timer is stopped now
close(t)
end
notify(t.cond)
finally
unlock(t.cond)
end
notify(t.cond)
nothing
end

Expand Down
2 changes: 1 addition & 1 deletion base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ eval(Core, :(NamedTuple{names,T}(args::T) where {names, T <: Tuple} =

import .Intrinsics: eq_int, trunc_int, lshr_int, sub_int, shl_int, bitcast, sext_int, zext_int, and_int

throw_inexacterror(f::Symbol, @nospecialize(T), val) = (@_noinline_meta; throw(InexactError(f, T, val)))
throw_inexacterror(f::Symbol, ::Type{T}, val) where {T} = (@_noinline_meta; throw(InexactError(f, T, val)))

function is_top_bit_set(x)
@_inline_meta
Expand Down
Loading