develooper Front page | perl.perl6.users | Postings from September 2017

Re: thread behavior

Thread Previous | Thread Next
Elizabeth Mattijsen
September 4, 2017 10:18
Re: thread behavior
Message ID:
> On 4 Sep 2017, at 10:44, JuhiMarcel LangbroekTimmerman <> wrote:
> Thanks for your anwer. I assume there are a few things I can rely on;
> - the main thread is where the code starts and will always have id 1

That can not be relied on in general, I’m afraid.  However, after some discussion, it appears that there is some support for an "is-initial-thread” method:

Note that the feeling is that you shouldn’t write code that depends on this.

> - a continuation of statements/blocks will always be excecuted on the same thread except for those hyper thingies which are again separate blocks or closures excecuted on other threads

I would say anything that either explicitly or implicitly does an await() in the future is not guaranteed to continue executing on the same thread.  Of course, the catch is in the “implicitly”: if you have complete control over your code, I guess you can be sure.  As soon as you start using 3rd party modules, I guess you could argue that all bets are off.

So this comes back to: why is it important to you to be sure that code continues to execute on the same thread?

> Is that correct?

Not sure  :-)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About