Skip to content

Make a CTask struct #64

@devmotion

Description

@devmotion

As discussed in TuringLang/Turing.jl#1237, it would be nice to implement the iteration interface for CTask since then it would be possible to use alternatives such as resumable functions in the particle filter implementations in Turing in a straightforward way (currently produce and consume statements are hardcoded). However, currently CTask is just a function that returns a Task for which stack copying has been enabled. Implementing the iteration interface for Task would be pretty bad type piracy (BTW Base.copy(::Task) in the current code is also type piracy). To avoid this I suggest adding a CTask struct that is defined as

struct CTask
	task::Task
end

Then Base.copy and Base.iterate could be implemented without committing type piracy. The downside would be that one would probably have to forward a bunch of methods defined for Task (such istaskstarted etc.) to task.

Do you think I should give it a try, or are there any other suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions