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

Schedulers don't appear to be workingfor me, tried several configurations. #9

Closed
garethhu opened this issue Feb 23, 2021 · 1 comment

Comments

@garethhu
Copy link

garethhu commented Feb 23, 2021

I have two functions that deal with adding to the subject

function source!(src::Source{T}) where T Subject(T, scheduler = AsyncScheduler()) do subject start_consume!(src, subject) end end

function start_consume!(src::Source{T}, consumer) where T while true msg = src.pollFn() if !isnothing(msg) next!(consumer, msg) else yield() end end end

When I replace Subject(T, scheduler = AsyncScheduler()) with make(T) everything works. However I want to run multiple queues on the same scheduler, I have tried running queues by looping through them and using @spawn and this didn't work it ran the first queue but the second did not execute at all. Consequently, my new approach is to give both queues the same scheduler so that the work is distributed between them. But currently, I can't get one queue running with a scheduler.

@garethhu garethhu changed the title Schedulers don't appear to be working, unless im using them wrong. Schedulers don't appear to be workingfor me, tried several configurations. Feb 23, 2021
@bvdmitri
Copy link
Member

Hi @garethhu,

I'm not sure if I understand what you are trying to achieve and I also cannot execute your code because I do not have an access to the Source structure. Also this piece of code cannot work since Subject does not accept a function as a first argument to their constructor (make(T) does)

Subject(T) do subject 
    ...
end

Consider using just:

subject = Subject(T)

But to answer your question I can clarify some things about schedulers in Rocket package. They are indeed considered to be an experimental feature and poorly documented. But in any case AsyncScheduler is not supposed to run different sources on the same async queue. It just simply spawns a new Julia Task for every new subscriber and there is no way to run multiple sources on the same queue using AsyncScheduler. Rocket.jl does not implement asynchronous queues and uses Julia internal scheduler to schedule different Tasks if needed.

What you can probably try is to use scheduler = PostponeScheduler().

scheduler = PostponeScheduler()
subject1 = Subject(T, scheduler = scheduler)
subject2 = Subject(T, scheduler = scheduler)

It synchronously adds incoming messages and subscriptions to one single queue. You can release queue with release!(scheduler) (executes actions added before calling release!) or with wait(scheduler) (executes actions added both before and after calling wait).

bvdmitri added a commit that referenced this issue Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants