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:21:09 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 BA150161314; Wed, 21 Dec 2016 17:21:08 -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 A876B161316 for ; Wed, 21 Dec 2016 17:20:24 -0500 (EST) Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) by mailbackend.panix.com (Postfix) with ESMTP id 9DBE813F41 for ; Wed, 21 Dec 2016 17:20:23 -0500 (EST) Received: by panix3.panix.com (Postfix, from userid 20529) id 571212EB52; 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.571212EB52-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.157.6.13 with SMTP id 13mr3288221otn.5.1482076445050; Sun, 18 Dec 2016 07:54:05 -0800 (PST) X-Received: by 10.157.17.167 with SMTP id v36mr606984otf.12.1482076445017; Sun, 18 Dec 2016 07:54:05 -0800 (PST) Path: reader1.panix.com!panix!usenet.stanford.edu!b123no1356385itb.0!news-out.google.com!c1ni3356itd.0!nntp.google.com!75no1350456ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.c++ Date: Sun, 18 Dec 2016 07:54: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: <6d72eead-14c9-4db9-a9c6-f68c2b27f1a4-at-googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <01dac413-7c0b-4731-b97f-52efbdfdb23f-at-googlegroups.com> Subject: Re: Threads and Object Methods From: =?UTF-8?B?w5bDtiBUaWli?= Injection-Date: Sun, 18 Dec 2016 15:54:05 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Lines: 45 Xref: panix comp.lang.c++:1126113
On Sunday, 18 December 2016 16:36:32 UTC+2, ruben safir wrote: > On 12/18/2016 06:09 AM, =C3=96=C3=B6 Tiib wrote: > > 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 stati= c > >> to the class > >> > >> > >> such as std::thread paint(read_chunk); > >> paint.detach(); > >> > >> > >> where read_chunk is an method of an object of class Images. > >=20 > > Again some voodoo trying-out nonsense that we can't even=20 > > copy-paste and run? :-/ The 'std::thread' *can* use non-static > > methods. However the caller has to supply arguments (starting=20 > > from 'this') to it. > >=20 > > #include > > #include > >=20 > > struct Reader=20 > > { > > void read_chunk() > > { > > std::cout << "quod erat demonstrandum" << std::endl; > > } > > }; > >=20 > > int main() > > { > > std::thread paint(&Reader::read_chunk, Reader()); > > paint.join(); > > } > >=20 > > See? It is easy peasy. > >=20 >=20 > if you call it like that it loses its context of the object that > instantated it which, especially in this case, it needs in order to do > its job.
Reading comprehension problem detected. Nah, just drop programming. There are easier jobs. Programming is not for you, sorry. -- end of forwarded message -- _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|