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:10 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 32AD4161318; Wed, 21 Dec 2016 17:21:10 -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 B729E161311 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 9119413F3F for ; Wed, 21 Dec 2016 17:20:23 -0500 (EST) Received: by panix3.panix.com (Postfix, from userid 20529) id 482832EB50; 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.482832EB50-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 -- Path: reader1.panix.com!panix!not-for-mail From: ruben safir Newsgroups: comp.lang.c++ Subject: Re: Threads and Object Methods Date: Sun, 18 Dec 2016 09:36:24 -0500 Organization: PANIX Public Access Internet and UNIX, NYC Lines: 40 Message-ID: References: <6d72eead-14c9-4db9-a9c6-f68c2b27f1a4-at-googlegroups.com> NNTP-Posting-Host: www.mrbrklyn.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: reader1.panix.com 1482071784 26575 96.57.23.82 (18 Dec 2016 14:36:24 GMT) X-Complaints-To: abuse-at-panix.com NNTP-Posting-Date: Sun, 18 Dec 2016 14:36:24 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 In-Reply-To: <6d72eead-14c9-4db9-a9c6-f68c2b27f1a4-at-googlegroups.com> Xref: panix comp.lang.c++:1126112
On 12/18/2016 06:09 AM, ?? 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 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. >
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. -- end of forwarded message -- _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|