Skip to content

Commit 123cb2e

Browse files
authored
Merge pull request #213 from tkf/hooks
Avoid serializing Base.repl_hooks and Base.package_callbacks
2 parents fc73e25 + 532f6bc commit 123cb2e

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

src/incremental.jl

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,67 @@ function ExitHooksEnd()
4747
"""
4848
end
4949

50+
function PackageCallbacksStart()
51+
"""
52+
package_callbacks_copy = copy(Base.package_callbacks)
53+
empty!(Base.package_callbacks)
54+
"""
55+
end
56+
57+
function PackageCallbacksEnd()
58+
"""
59+
empty!(Base.package_callbacks)
60+
append!(Base.package_callbacks, package_callbacks_copy)
61+
"""
62+
end
63+
64+
function REPLHooksStart()
65+
"""
66+
repl_hooks_copy = copy(Base.repl_hooks)
67+
empty!(Base.repl_hooks)
68+
"""
69+
end
70+
71+
function REPLHooksEnd()
72+
"""
73+
empty!(Base.repl_hooks)
74+
append!(Base.repl_hooks, repl_hooks_copy)
75+
"""
76+
end
77+
78+
function DisableLibraryThreadingHooksStart()
79+
"""
80+
if isdefined(Base, :disable_library_threading_hooks)
81+
disable_library_threading_hooks_copy = copy(Base.disable_library_threading_hooks)
82+
empty!(Base.disable_library_threading_hooks)
83+
end
84+
"""
85+
end
86+
87+
function DisableLibraryThreadingHooksEnd()
88+
"""
89+
if isdefined(Base, :disable_library_threading_hooks)
90+
empty!(Base.disable_library_threading_hooks)
91+
append!(Base.disable_library_threading_hooks, disable_library_threading_hooks_copy)
92+
end
93+
"""
94+
end
95+
5096
"""
5197
The command to pass to julia --output-o, that runs the julia code in `path` during compilation.
5298
"""
5399
function PrecompileCommand(path)
54-
ExitHooksStart() * InitBase() * InitREPL() * Include(path) * ExitHooksEnd()
100+
ExitHooksStart() *
101+
PackageCallbacksStart() *
102+
REPLHooksStart() *
103+
DisableLibraryThreadingHooksStart() *
104+
InitBase() *
105+
InitREPL() *
106+
Include(path) *
107+
DisableLibraryThreadingHooksEnd() *
108+
REPLHooksEnd() *
109+
PackageCallbacksEnd() *
110+
ExitHooksEnd()
55111
end
56112

57113

0 commit comments

Comments
 (0)