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:36 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 CBB1D161314; Wed, 21 Dec 2016 17:21:35 -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 8CB37161314 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 594E213F39 for ; Wed, 21 Dec 2016 17:20:24 -0500 (EST) Received: by panix3.panix.com (Postfix, from userid 20529) id B6E9E2EB57; 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.B6E9E2EB57-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!bloom-beacon.mit.edu!bloom-beacon.mit.edu!168.235.88.217.MISMATCH!feeder.erje.net!2.us.feeder.erje.net!news.ripco.com!news.glorb.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!post01.iad.highwinds-media.com!fx08.iad.POSTED!not-for-mail X-Newsreader: xrn 9.03-beta-14-64bit Sender: scott-at-dragon.sl.home (Scott Lurndal) From: scott-at-slp53.sl.home (Scott Lurndal) Reply-To: slp53-at-pacbell.net Subject: Re: Threads and Object Methods Newsgroups: comp.lang.c++ References: <6d72eead-14c9-4db9-a9c6-f68c2b27f1a4-at-googlegroups.com> <7pSdnevF5InTn8rFnZ2dnUU78W3NnZ2d-at-brightview.co.uk> Lines: 26 Message-ID: X-Complaints-To: abuse-at-usenetserver.com NNTP-Posting-Date: Mon, 19 Dec 2016 14:30:16 UTC Organization: UsenetServer - www.usenetserver.com Date: Mon, 19 Dec 2016 14:30:16 GMT X-Received-Bytes: 1739 X-Received-Body-CRC: 3533625061 Xref: panix comp.lang.c++:1126145
ruben safir writes: >On 12/18/2016 04:40 PM, Vir Campestris wrote: >> You're missing the second parameter to the function. Perhaps if he'd >> written >> >> Reader foo; >> std::thread paint(&reader::read_chunk, &foo); >> >> it would have made more sense to you. You can pass args to the function, >> which may include a pointer to an object of the type. I prefer to pass a >> pointer to a static member function for the first parameter which takes >> a pointer to an object of the class and invokes a corresponding >> non-static member. >> >> Andy > > >Not really.
Yes, really.
Have a static method in class reader as your thread entry point taking a single void * argument. Pass the object pointer as the argument. In the static method, you can cast the argument to a pointer to reader and use that to access object data directly or as Tiib points out, use it to invoke a member function. -- end of forwarded message -- _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|