Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #5236 > unrolled thread

random_device-question

Started byBonita Montero <Bonita.Montero@gmail.com>
First post2019-10-12 09:36 +0200
Last post2019-10-12 09:40 +0200
Articles 8 — 2 participants

Back to article view | Back to comp.programming.threads


Contents

  random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 09:36 +0200
    Re: random_device-question Melzzzzz <Melzzzzz@zzzzz.com> - 2019-10-12 07:39 +0000
      Re: random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 09:41 +0200
        Re: random_device-question Melzzzzz <Melzzzzz@zzzzz.com> - 2019-10-12 09:10 +0000
          Re: random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 11:30 +0200
            Re: random_device-question Melzzzzz <Melzzzzz@zzzzz.com> - 2019-10-12 09:39 +0000
              Re: random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 11:42 +0200
    Re: random_device-question Bonita Montero <Bonita.Montero@gmail.com> - 2019-10-12 09:40 +0200

#5236 — random_device-question

FromBonita Montero <Bonita.Montero@gmail.com>
Date2019-10-12 09:36 +0200
Subjectrandom_device-question
Message-ID<qnrvpo$60b$1@news.albasani.net>
Is there any guarantee the standard makes that random_device shoudn't
start at the same internal state for all new threads, i.e. the output
of the following code is likey to be different on both lines?

#include <iostream>
#include <mutex>
#include <random>
#include <thread>

using namespace std;

int main()
{
     auto thr = []()
     {
         static mutex  mtx;
         random_device rd;
         mtx.lock();
         cout << rd() << endl;
         mtx.unlock();
     };
     thread t1( thr );
     thread t2( thr );
     t1.join();
     t2.join();
}

[toc] | [next] | [standalone]


#5237

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2019-10-12 07:39 +0000
Message-ID<irfoF.1326006$qU.799212@fx20.am4>
In reply to#5236
On 2019-10-12, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> Is there any guarantee the standard makes that random_device shoudn't
> start at the same internal state for all new threads, i.e. the output
> of the following code is likey to be different on both lines?

No.


-- 
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi 
bili naoruzani. -- Mladen Gogala

[toc] | [prev] | [next] | [standalone]


#5239

FromBonita Montero <Bonita.Montero@gmail.com>
Date2019-10-12 09:41 +0200
Message-ID<qns02r$6bv$3@news.albasani.net>
In reply to#5237
>> Is there any guarantee the standard makes that random_device shoudn't
>> start at the same internal state for all new threads, i.e. the output
>> of the following code is likey to be different on both lines?

> No.

Maybe, but I don't believe _you_ since you're an idiot.

[toc] | [prev] | [next] | [standalone]


#5240

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2019-10-12 09:10 +0000
Message-ID<SLgoF.1058899$WI2.623950@fx34.am4>
In reply to#5239
On 2019-10-12, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> Is there any guarantee the standard makes that random_device shoudn't
>>> start at the same internal state for all new threads, i.e. the output
>>> of the following code is likey to be different on both lines?
>
>> No.
>
> Maybe, but I don't believe _you_ since you're an idiot.

I guess that highly depends on compiler and OS... why don't you try out?
>


-- 
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi 
bili naoruzani. -- Mladen Gogala

[toc] | [prev] | [next] | [standalone]


#5241

FromBonita Montero <Bonita.Montero@gmail.com>
Date2019-10-12 11:30 +0200
Message-ID<qns6f3$nue$1@news.albasani.net>
In reply to#5240
>> Maybe, but I don't believe _you_ since you're an idiot.

> I guess that highly depends on compiler and OS...
> why don't you try out?

This wouldn't help answering my question.

[toc] | [prev] | [next] | [standalone]


#5242

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2019-10-12 09:39 +0000
Message-ID<ubhoF.887947$ir6.798674@fx16.am4>
In reply to#5241
On 2019-10-12, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> Maybe, but I don't believe _you_ since you're an idiot.
>
>> I guess that highly depends on compiler and OS...
>> why don't you try out?
>
> This wouldn't help answering my question.
You are stupid...

-- 
press any key to continue or any other to quit...
U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec
Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi 
bili naoruzani. -- Mladen Gogala

[toc] | [prev] | [next] | [standalone]


#5243

FromBonita Montero <Bonita.Montero@gmail.com>
Date2019-10-12 11:42 +0200
Message-ID<qns76u$mij$1@news.albasani.net>
In reply to#5242
>>> I guess that highly depends on compiler and OS...
>>> why don't you try out?

>> This wouldn't help answering my question.

> You are stupid...

You are stupud because you don't understand that when a standard
library behaves like I wish it may not be portable because this
behaviour might not be specified. So it wouldn't be clever to
rely on this only because an implementation has this behaviour.
Boy, you're always telling stupid stuff. Stop writing about such
things; it's always embarrassing for you.

[toc] | [prev] | [next] | [standalone]


#5238

FromBonita Montero <Bonita.Montero@gmail.com>
Date2019-10-12 09:40 +0200
Message-ID<qns01c$6bv$2@news.albasani.net>
In reply to#5236
Oh, wrong newsgroup.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming.threads


csiph-web