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

Re: thread behavior

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
September 4, 2017 10:18
Subject:
Re: thread behavior
Message ID:
C65B4E97-021B-40BD-BADF-A4CE5CC36F0B@dijkmat.nl
> On 4 Sep 2017, at 10:44, JuhiMarcel LangbroekTimmerman <mt1957.2@gmail.com> 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:

   https://irclog.perlgeek.de/perl6-dev/2017-09-04#i_15112552

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  :-)


Liz
Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About