Skip to content

Commit efa4e58

Browse files
committed
Fixed some bugs in plugin merge
1 parent cbff40f commit efa4e58

5 files changed

Lines changed: 11 additions & 15 deletions

File tree

benchmarks/run_benchmarks.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
include("..\\src\\Cruise.jl")
2-
3-
using .Cruise
1+
using Cruise
42
using BenchmarkTools
53

64
include("BenchTypes.jl")

src/plugin/core.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@ mutable struct CRPluginNode{T,S}
4646
obj::T
4747
mainthread::Bool
4848
deps::PluginDict
49-
children::Vector{CRPluginNode}
5049
status::CRSubject{CRPluginStatus}
5150
capability::S
5251
lasterr::Exception
5352

5453
## Constructors
5554

56-
CRPluginNode(obj::T; mainthread=false) where T = new{T,Any}(-1, obj, mainthread, PluginDict(), CRPluginNode[], CRSubject(PLUGIN_OFF))
57-
CRPluginNode(obj::T, cap::S; mainthread=false) where {T, S<:Any} = new{T,S}(-1, obj, mainthread, PluginDict(), CRPluginNode[], CRSubject(PLUGIN_OFF), cap)
55+
CRPluginNode(obj::T; mainthread=false) where T = new{T,Any}(-1, obj, mainthread, PluginDict(), CRSubject(PLUGIN_OFF))
56+
CRPluginNode(obj::T, cap::S; mainthread=false) where {T, S<:Any} = new{T,S}(-1, obj, mainthread, PluginDict(), CRSubject(PLUGIN_OFF), cap)
5857
end
5958

6059
"""

src/plugin/operations.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ function add_dependency!(sg::CRPlugin, from::Int, to::Int; sort=true)
135135
p = sg.idtonode[from]
136136
c = sg.idtonode[to]
137137
c.deps[typeof(p.obj)] = WeakRef(p)
138-
push!(p.children, c)
139138
if sort
140139
sg.sort_cache = topological_sort(get_graph(sg))
141140
sg.parallel_cache = compute_parallel_levels(sg)
@@ -153,11 +152,7 @@ function remove_dependency!(sg::CRPlugin, from::Int, to::Int; sort=true)
153152
p = sg.idtonode[from]
154153
c = sg.idtonode[to]
155154
delete!(c.deps,typeof(p.obj))
156-
idx = findfirst(isequal(c), p.children)
157-
if idx != -1
158-
p.children[end], p.children[idx] = p.children[idx], p.children[end]
159-
pop!(p.children)
160-
end
155+
161156
if sort
162157
sg.sort_cache = topological_sort(get_graph(sg))
163158
sg.parallel_cache = compute_parallel_levels(sg)
@@ -205,7 +200,10 @@ function merge_graphs!(sg1::CRPlugin, sg2::CRPlugin; sort=true)
205200
end
206201
end
207202

208-
sort && (sg1.sort_cache = topological_sort(get_graph(sg1)))
203+
if sort
204+
sg1.sort_cache = topological_sort(get_graph(sg1))
205+
sg1.parallel_cache = compute_parallel_levels(sg1)
206+
end
209207

210208
return sg1
211209
end

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Cruise
1+
include("..\\src\\Cruise.jl")
2+
3+
using .Cruise
24
using Test
35

46
include("test_temp_storage.jl")

test/test_plugins.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ end
102102

103103
remove_dependency!(sg, a, b)
104104
@test !haskey(sg.idtonode[b].deps, Symbol(DummySys))
105-
@test !(sg.idtonode[b] in sg.idtonode[a].children)
106105
end
107106

108107
@testset "merge_graphs! merges without duplicating identical system types" begin

0 commit comments

Comments
 (0)