delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/03/15/20:00:49

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:message-id:date:mime-version
:content-type:content-transfer-encoding; q=dns; s=default; b=l3r
TXHseZ/1RV0hgZ7rHM6tibbjd0ly/ibaMaiTNIOLZ4sVdyGThE2+BPYW9LCavfe/
stYlRCFjrSiCPc1HwtBVZLZ2ftXQ9AA5/uJaO7btnrOMj8rq24+696o+d/DfBBto
aPPmVEwXfJ3vK8jKkyKDDFNVG+BCoEXXvGXqy0YM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:to:from:subject:message-id:date:mime-version
:content-type:content-transfer-encoding; s=default; bh=V0hdA3xdy
hglSC27i5vgPkWAUXw=; b=tvagEBZQOxxV30iW8iRDWtBr/FyU1J/G1xnCr8AoB
iHP1O+puHpOllNVSFOFVe/H2NseltYrFra8nCh6tkiZOpSBlq+t6YpbY1UWh7mpU
QQRwFMq+AM8p9H3SemZGc0cQw5OQkmsrfhM1fOwve39CW4DV43q7X5dwTJAObEOW
Zg=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-0.0 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:D*mit.edu, H*r:User, Hx-spam-relays-external:!Symantec, H*RU:!Symantec
X-HELO: dmz-mailsec-scanner-2.mit.edu
To: cygwin AT cygwin DOT com
From: Ilya Razenshteyn <ilyaraz AT mit DOT edu>
Subject: std::async from C++11 does not work
Message-ID: <56E8A202.4060600@mit.edu>
Date: Tue, 15 Mar 2016 20:00:02 -0400
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
MIME-Version: 1.0
X-IsSubscribed: yes

Hi all,

I'm trying to compile and run the below code. As a result, only one copy 
of "f" is being executed at a time, that is, no new threads are spawned. 
Does anyone know what's going on?

cygwin 2.4.1, gcc 5.3.0, compilation options are "g++ test.cpp -o test 
-O3 -Wall -std=c++11 -lpthread".


Ilya

#include <future>
#include <iostream>

using namespace std;

void f(int id) {
   for (int i = 0; i < 100000; ++i) {
     cout << id << endl;
   }
}

int main() {
   std::async(std::launch::async, &f, 1);
   std::async(std::launch::async, &f, 2);
   return 0;
}

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019