MESSAGE
DATE | 2016-12-21 |
FROM | Ruben Safir
|
SUBJECT | Subject: [Learn] (fwd) Re: Threads and Object Methods
|
From learn-bounces-at-nylxs.com Wed Dec 21 17:20:27 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id DA5A516131B; Wed, 21 Dec 2016 17:20:26 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by mrbrklyn.com (Postfix) with ESMTP id 9F456161311 for ; Wed, 21 Dec 2016 17:20:23 -0500 (EST) Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) by mailbackend.panix.com (Postfix) with ESMTP id 6806013F2C for ; Wed, 21 Dec 2016 17:20:23 -0500 (EST) Received: by panix3.panix.com (Postfix, from userid 20529) id 301C82EB51; Wed, 21 Dec 2016 17:20:23 -0500 (EST) From: Ruben Safir To: learn-at-nylxs.com User-Agent: tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (NetBSD/6.1.5 (i386)) Message-Id: <20161221222023.301C82EB51-at-panix3.panix.com> Date: Wed, 21 Dec 2016 17:20:23 -0500 (EST) Subject: [Learn] (fwd) Re: Threads and Object Methods X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
-- forwarded message -- X-Received: by 10.99.1.201 with SMTP id 192mr6541663pgb.156.1482059344831; Sun, 18 Dec 2016 03:09:04 -0800 (PST) X-Received: by 10.157.11.120 with SMTP id p53mr578929otd.19.1482059344788; Sun, 18 Dec 2016 03:09:04 -0800 (PST) Path: reader1.panix.com!panix!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!b123no1289487itb.0!news-out.google.com!c1ni2306itd.0!nntp.google.com!75no1282974ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.c++ Date: Sun, 18 Dec 2016 03:09:04 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse-at-google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=85.253.221.3; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK NNTP-Posting-Host: 85.253.221.3 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6d72eead-14c9-4db9-a9c6-f68c2b27f1a4-at-googlegroups.com> Subject: Re: Threads and Object Methods From: =?UTF-8?B?w5bDtiBUaWli?= Injection-Date: Sun, 18 Dec 2016 11:09:04 +0000 Content-Type: text/plain; charset=UTF-8 Bytes: 1955 Lines: 33 Xref: panix comp.lang.c++:1126108
On Sunday, 18 December 2016 11:49:07 UTC+2, ruben safir wrote: > Why can't the threads library handle object methods that are not static > to the class > > > such as std::thread paint(read_chunk); > paint.detach(); > > > where read_chunk is an method of an object of class Images.
Again some voodoo trying-out nonsense that we can't even copy-paste and run? :-/ The 'std::thread' *can* use non-static methods. However the caller has to supply arguments (starting from 'this') to it.
#include #include
struct Reader { void read_chunk() { std::cout << "quod erat demonstrandum" << std::endl; } };
int main() { std::thread paint(&Reader::read_chunk, Reader()); paint.join(); }
See? It is easy peasy. -- end of forwarded message -- _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|