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

Interrupting tasks in different threads assert bug #443

Closed
magicl opened this Issue Dec 20, 2013 · 7 comments

Comments

Projects
None yet
2 participants
@magicl

magicl commented Dec 20, 2013

Assert in core.d should also check for 'null'

    assert(caller.thread is this.thread && 
           caller.thread !is null && 
           this.thread !is null, "Interrupting tasks in different threads is not yet supported.");
@magicl

This comment has been minimized.

Show comment
Hide comment
@magicl

magicl Dec 20, 2013

A bit quick there.. This makes it work better. Case (if I remember correctly) is when the main 'task' has not been created by vibe.. 'thread' is null

assert(caller.thread is this.thread ||
           caller.thread is null ||
           this.thread is null, "Interrupting tasks in different threads is not yet supported.");

magicl commented Dec 20, 2013

A bit quick there.. This makes it work better. Case (if I remember correctly) is when the main 'task' has not been created by vibe.. 'thread' is null

assert(caller.thread is this.thread ||
           caller.thread is null ||
           this.thread is null, "Interrupting tasks in different threads is not yet supported.");
@magicl

This comment has been minimized.

Show comment
Hide comment
@magicl

magicl Mar 1, 2014

Is this an ok fix? In that case, I can submit a pull-request for it..

magicl commented Mar 1, 2014

Is this an ok fix? In that case, I can submit a pull-request for it..

s-ludwig added a commit that referenced this issue May 7, 2014

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig May 7, 2014

Member

I've used assert(caller != Task.init) to assert that the caller is a valid task. This needs to be the case, because the interrupted task gets resumed and expects to be run within a running event loop.

With some effort it would be possible to make interruption from foreign threads and from outside of the event loop work, too.

Member

s-ludwig commented May 7, 2014

I've used assert(caller != Task.init) to assert that the caller is a valid task. This needs to be the case, because the interrupted task gets resumed and expects to be run within a running event loop.

With some effort it would be possible to make interruption from foreign threads and from outside of the event loop work, too.

@magicl

This comment has been minimized.

Show comment
Hide comment
@magicl

magicl May 8, 2014

I have an event-loop run in a thread created outside of vibed. In this thread, I run the event loop, but also do other things. If I try to interrupt a task from the thread (outside any of the tasks spawned by the thread), I get this assert.. How can I fix this? It is not an invalid case, since I only interrupt tasks that are spawned by the same thread.

magicl commented May 8, 2014

I have an event-loop run in a thread created outside of vibed. In this thread, I run the event loop, but also do other things. If I try to interrupt a task from the thread (outside any of the tasks spawned by the thread), I get this assert.. How can I fix this? It is not an invalid case, since I only interrupt tasks that are spawned by the same thread.

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig May 8, 2014

Member

So do you use a manual processEvents style event loop, so that you can still call other things while it is running? I didn't think of this, but it should be safe to make an exception for that.

Member

s-ludwig commented May 8, 2014

So do you use a manual processEvents style event loop, so that you can still call other things while it is running? I didn't think of this, but it should be safe to make an exception for that.

s-ludwig added a commit that referenced this issue May 8, 2014

Enable Task.join/interrupt to work outside of the event loop for task…
…s of the same thread. See #443.

This makes it possible to use those functions outside of a task before the event loop has started, or when the event loop is manually run using processEvents().
@magicl

This comment has been minimized.

Show comment
Hide comment
@magicl

magicl May 9, 2014

Yes, I use 'processEvents'. Thanks. I will try it out when the next release comes.

magicl commented May 9, 2014

Yes, I use 'processEvents'. Thanks. I will try it out when the next release comes.

@magicl magicl closed this May 9, 2014

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig May 9, 2014

Member

You could also try it out right now by running dub upgrade --prerelease to get the latest 0.7.20-beta.1.

Member

s-ludwig commented May 9, 2014

You could also try it out right now by running dub upgrade --prerelease to get the latest 0.7.20-beta.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment