@@ -30,11 +30,14 @@ Base.@kwdef struct Trajectory{C,S,T}
3030 function Trajectory (container:: C , sampler:: S , controller:: T ) where {C,S,T<: AsyncInsertSampleRatioController }
3131 t = Threads. @spawn while true
3232 for msg in controller. ch_in
33- if msg. f === Base. push! || msg. f === Base. append!
34- n_pre = length (container)
35- msg. f (container, msg. args... ; msg. kw... )
36- n_post = length (container)
37- controller. n_inserted += n_post - n_pre
33+ if msg. f === Base. push!
34+ x, = msg. args
35+ msg. f (container, x)
36+ controller. n_inserted += 1
37+ elseif msg. f === Base. append!
38+ x, = msg. args
39+ msg. f (container, x)
40+ controller. n_inserted += length (x)
3841 else
3942 msg. f (container, msg. args... ; msg. kw... )
4043 end
@@ -78,10 +81,10 @@ struct CallMsg
7881 kw:: Any
7982end
8083
81- Base. push! (t:: Trajectory{<:Any,<:Any,<:AsyncInsertSampleRatioController} , args ... ; kw ... ) = put! (t. controller. ch_in, CallMsg (Base. push!, args, kw ))
82- Base. append! (t:: Trajectory{<:Any,<:Any,<:AsyncInsertSampleRatioController} , args ... ; kw ... ) = put! (t. controller. ch_in, CallMsg (Base. append!, args, kw ))
84+ Base. push! (t:: Trajectory{<:Any,<:Any,<:AsyncInsertSampleRatioController} , x ) = put! (t. controller. ch_in, CallMsg (Base. push!, (x,), NamedTuple () ))
85+ Base. append! (t:: Trajectory{<:Any,<:Any,<:AsyncInsertSampleRatioController} , x ) = put! (t. controller. ch_in, CallMsg (Base. append!, (x,), NamedTuple () ))
8386
84- function Base. append! (t:: Trajectory , x:: AbstractVector )
87+ function Base. append! (t:: Trajectory , x)
8588 append! (t. container, x)
8689 on_insert! (t. controller, length (x))
8790end
0 commit comments