MESSAGE
DATE | 2016-12-17 |
FROM | Ruben Safir
|
SUBJECT | Subject: [Learn] irc thread on the use of object methods in threads
|
From learn-bounces-at-nylxs.com Sat Dec 17 17:28:18 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 D485D161312; Sat, 17 Dec 2016 17:28:17 -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 5623B160E77 for ; Sat, 17 Dec 2016 17:28:12 -0500 (EST) Received: from [10.0.0.62] (www.mrbrklyn.com [96.57.23.82]) by mailbackend.panix.com (Postfix) with ESMTPSA id 3771D13AAA for ; Sat, 17 Dec 2016 17:28:11 -0500 (EST) To: learn-at-nylxs.com From: Ruben Safir Message-ID: Date: Sat, 17 Dec 2016 17:28:11 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Subject: [Learn] irc thread on the use of object methods in threads 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
3:53:37 PM - mrbrklyn: wow - I just learned I can't send a member function to a thread... which really sucks. 3:53:41 PM - XCE [~XCE-at-2601:646:8280:3280:849a:8bd9:9b61:dae7] entered the room. 3:53:53 PM - eraz: mrbrklyn: how would that even work. 3:53:58 PM - melita [~melita-at-2601:645:4000:ccd0:1092:2f75:1b74:5ab0] entered the room. 3:53:59 PM - megaTherion: makes not much sense 3:54:26 PM - litb: what do you mean by "send" 3:54:35 PM - mrbrklyn: why would it not work if the thread is inside an object. 3:54:42 PM - litb: can you please send the question to me 3:54:47 PM - mrbrklyn: I ask out of ignorance 3:54:48 PM - megaTherion: I agree, elaborate what send means in this context 3:55:31 PM - mrbrklyn: std::thread paint(read_chunk); 3:55:51 PM - mrbrklyn: where read_chunk is a member of on object of class Image 3:55:57 PM - minus: basically, you need to bind `this` 3:56:11 PM - megaTherion: I think "send" isnt really the best word for this ^^ 3:56:16 PM - mrbrklyn: minus, can you elaborate? 3:56:27 PM - litb: mrbrklyn, instead of read_chunk you need to say [this]{read_chunk();} 3:56:39 PM - minus: std::thread paint([this] { read_chunk(); }); should work 3:56:47 PM - minus: eh, i'm too slow :< 3:57:17 PM - minus: member functions take the this pointer of the object as first, hidden parameter 3:57:18 PM - mrbrklyn: with square brackets 3:57:36 PM - byte512 has left the room (Quit: Ping timeout: 252 seconds). 3:57:37 PM - litb: mrbrklyn, it is a lambda 3:57:58 PM - eraz: {[]{}();} 3:57:59 PM - geordi: 3:58:08 PM - litb: i would prefer one more paren 3:58:10 PM - mrbrklyn: ahhh . .. a whole new concept :) 3:58:20 PM - eraz: {[](){[](){}();};} 3:58:21 PM - geordi: 3:58:41 PM - eraz: <3 lambdas <3 3:58:42 PM - melita has left the room (Quit: Ping timeout: 258 seconds). 3:58:43 PM - salamanderrake [~quassel-at-2605:a000:1229:c036:39f4:3bbe:4bf0:c03] entered the room. 3:59:09 PM - litb: geordi, add *+ before first [ 3:59:09 PM - geordi: 3:59:17 PM - o]: ew 3:59:21 PM - minus: need =3D> for more concise lambdas 3:59:30 PM - megaTherion: indeed 3:59:31 PM - o]: geordi,show 3:59:31 PM - geordi: {*+[](){[](){}();};} 3:59:39 PM - eraz: geordi, replace * with ******* 3:59:40 PM - geordi: 3:59:46 PM - o]: :((((((((( 3:59:47 PM - litb: figured the lambda beard needs a proper nose with eye 3:59:54 PM - minus: how is that even valid 4:00:02 PM - Rarglepuff [~Rarglepuf-at-cpe-74-75-107-152.maine.res.rr.com] entered the room. 4:00:03 PM - o]: operator+ on lambdas huh 4:00:04 PM - eraz: geordi, replace {[] with {*******+[] 4:00:04 PM - geordi: error: wrong type argument to unary plus 4:00:06 PM - eraz: dammit 4:00:09 PM - minus: << +[]{}(); 4:00:09 PM - geordi: Same error. 4:00:26 PM - Rarglepuff has left the room (Quit: Remote host closed the connection). 4:00:32 PM - eraz: << (+[]{})(); 4:00:32 PM - geordi: error: no match for 'operator<<' in 'cout << (+ main(int, char**)::{}.main(int, char**)::::operator void (*)()())()' (operand types are 'ostream {aka ostream}' and 'void') 4:00:37 PM - litb: lol 4:00:43 PM - eraz: << (+[]{return int{}})(); 4:00:43 PM - geordi: error: expected ';' before '}' token 4:00:46 PM - eraz: << (+[]{return int{};})(); 4:00:46 PM - geordi: 0 4:00:49 PM - mrbrklyn: what is a lamda and why do I need it here? 4:00:54 PM - megaTherion: ... 4:00:57 PM - Rarglepuff [~Rarglepuf-at-cpe-74-75-107-152.maine.res.rr.com] entered the room. 4:00:58 PM - eraz: mrbrklyn: do you know what function objects are? 4:01:04 PM - o]: !grab mrbrklyn 4:01:05 PM - nolyc: By your command. 4:01:13 PM - litb: mrbrklyn, because a member function name evaluates to an rvalue of function type and the only supported operation on it is to call it right away 4:01:16 PM - willy23123 has left the room (Quit: Colloquy for iPhone - http://colloquy.mobi). 4:01:38 PM - megaTherion: mrbrklyn: you're C++98? 4:01:59 PM - eraz: mrbrklyn: well, actually, you could just watch this (very good) video on lambdas. https://youtu.be/WXeu4fj3zOs 4:02:01 PM - minus: std::thread doesn't exist in C++98, so he can't be 4:02:02 PM - urlgrabber [~urlgrabbe-at-www.ladio.me] entered the room. 4:02:31 PM - mrbrklyn: gcc version 6.2.1 20160830 (GCC) 4:02:54 PM - litb: mrbrklyn, alternatively, bind(&decay_t<*decltype(this)>::read_chunk, this) should work 4:02:55 PM - eraz: mrbrklyn: I think megaTherion was asking about your area of comfort regarding C++. 4:03:15 PM - megaTherion: comfort or knowledge :) 4:03:27 PM - megaTherion: was just curious 4:03:58 PM - minus: litb: not decltype(*this)? 4:04:03 PM - mrbrklyn: Well, I'm deaf so videos are not great 4:04:04 PM - litb: yes :D 4:04:05 PM - eraz: minus: that returns a reference. 4:04:17 PM - eraz: References don't have members. :) 4:04:23 PM - megaTherion: mrbrklyn: then you want a book 4:04:25 PM - mrbrklyn: C++, fairly familiar going back to using it since 1994 4:04:42 PM - mrbrklyn: never threading until now 4:04:45 PM - megaTherion: mrbrklyn: effective modern C++ by Scott Meyers might bring you up to C++11/14 then 4:04:49 PM - allen29 [~all-at-unaffiliated/allen29] entered the room. 4:04:59 PM - minus: ^ reading that right now, good book 4:05:19 PM - eraz: Still on the way (shipping). Excited to have a copy. :) 4:05:34 PM - mrbrklyn: C++ concurancy - anthony williams 4:05:35 PM - mrbrklyn: ? 4:06:20 PM - litb: yes get it 4:06:33 PM - matkatmusic [~matkatmus-at-pool-173-56-226-234.nycmny.fios.verizon.net] entered the room. 4:07:59 PM - mrbrklyn: I have the latest C++FifthPrimer Edition Stanley B. Lippman Jos=C3=A9e Lajoie Barbara E. Moo also 4:09:19 PM * eraz gives mrbrklyn a thumbs up 4:09:31 PM - KAHR-Alpha has left the room (Quit: Remote host closed the connection). 4:11:24 PM - minus: eraz =E2=94=82 minus: that returns a reference. =E2=86= =90 decay_t instead of decay_t<*decltype(this)> is what i meant 4:11:46 PM - Sylph-DS [~Sylph-at-145.136.49.141] entered the room. 4:13:15 PM - eraz: minus: ah, I thought somethingl looked off about that. :P 4:13:29 PM - mrbrklyn: The C++ Programming Language Fourth Edition Bjarne Stroustrup also 4:13:37 PM - RedOrangeZ [~RedOrange-at-c-73-30-227-113.hsd1.pa.comcast.net] entered the room. 4:13:38 PM - FreeBirdLjj has left the room (Quit: Remote host closed the connection). 4:13:55 PM - blackbird_ [~blackbird-at-197.2.130.228] entered the room. 4:15:15 PM - AquaL1te has left the room (Quit: leaving). 4:16:17 PM - blackbird1 has left the room (Quit: Ping timeout: 268 seconds). 4:17:48 PM - mrbrklyn: how about creating a warpper function for the member call? 4:18:18 PM - megaTherion: mrbrklyn: the lambda results in an closure, which is exacly such a thing 4:18:28 PM - mrbrklyn: http://stackoverflow.com/questions/22749787/invalid-use-of-non-static-membe= r-function-in-qt#22749866 4:18:58 PM - mrbrklyn: OK what is the inherent error that I'm hitting though 4:19:17 PM - megaTherion: mrbrklyn: if you're not comfortable with lambda's (yet), you can also use std::bind which does what you want as well 4:19:19 PM - o]: !give mrbrklyn basic 4:19:21 PM - nolyc: mrbrklyn: If you're very new to C++ and have not yet found your footing, ##c++-basic may be able to guide you along your first steps. 4:19:26 PM - mrbrklyn: I'm not understanding the nature of the problem, even though I can use a receipe to fix it 4:19:31 PM - o]: ahh they changed the factoid :( why 4:19:33 PM - megaTherion: (you may know bind1st, bind2nd) 4:19:52 PM - eraz: o]: it's a lot nicer. :P 4:19:55 PM - o]: megaTherion: eww. stop throwing shit at the channel 4:20:05 PM - mrbrklyn: why can't the thread object use the implied this-> 4:20:07 PM - eraz: megaTherion: do not mention those horrible things. 4:20:17 PM - megaTherion: o]: what's the issue? 4:20:27 PM - o]: you are recommending deprecated shit here. don't do that 4:20:28 PM - megaTherion: arent they valid in C++98? 4:20:33 PM - megaTherion: haha 4:20:40 PM - megaTherion: o]: you seem to live in an ideal world 4:20:49 PM * megaTherion still has to do C++98 coding from time to time 4:20:49 PM - o]: it is almost 2017 4:20:56 PM - megaTherion: o]: old projects wont give a shit 4:21:04 PM - o]: I already refactored all of them 4:21:06 PM - megaTherion: they are there and they wont go away 4:21:14 PM - megaTherion: o]: and you paid for refactoring? 4:21:17 PM - o]: your shit doesn't go away because you are lazy 4:21:23 PM - megaTherion: *lool* 4:21:25 PM - o]: or avaricious 4:21:39 PM - megaTherion: o]: Im not a freelancer, I dont decide what will be done or not 4:21:56 PM - o]: wtf being a freelancer has to do or not with doing a good job? 4:22:08 PM - megaTherion: you're completly missing the point 4:22:17 PM - o]: I don't live in an ideal world. you are the one who lives in a distopic world 4:22:18 PM - megaTherion: Im not the one who decides if the code will be refactored or not 4:22:23 PM - megaTherion: pure and simple 4:22:30 PM - anuxivm [~anuxi-at-92.177.99.40] entered the room. 4:22:55 PM - o]: please don't spread your bad habits here 4:23:06 PM - megaTherion: Im only telling you from real life work :) 4:23:08 PM - megaTherion: not your IRC dreams 4:23:17 PM - o]: and you are implying that I don't do real work 4:23:19 PM - eraz: lol 4:23:28 PM - minus: straying off topic a bit here 4:23:28 PM - o]: you are so full of yourself 4:23:31 PM - megaTherion: Im implying that you might have less than 10y experience 4:23:32 PM - o]: yup 4:23:37 PM - martinium has left the room (Quit: Ping timeout: 250 seconds). 4:23:47 PM - megaTherion: C++ is around a lot longer 4:23:48 PM - o]: megaTherion: I code since 1985, you asshole 4:24:00 PM - P4Titan: let's not hate guys 4:24:05 PM - P4Titan: c'mon 4:24:10 PM * eraz is a 96... ._. 4:24:22 PM - minus: go to sleep kiddo 4:24:23 PM - megaTherion: o]: I'll simply ignore you, you're too immature for my taste 4:24:35 PM - o]: awesome. good bye 4:24:43 PM - melita [~melita-at-2601:645:4000:ccd0:1092:2f75:1b74:5ab0] entered the room. 4:24:49 PM - eraz: !next2 (x2) 4:24:54 PM - eraz: wait really? 4:24:57 PM - eraz: !next2 4:24:57 PM - o]: !give megaTherion restrict 4:24:58 PM - nolyc: Another dissatisfied customer, next! 4:24:59 PM - nolyc: megaTherion: If you insist on using only a restricted subset of C++, then know that our interest in helping you is inversely proportional to the severity of the restrictions. 4:25:11 PM - megaTherion: *shrugs* 4:25:13 PM - eraz: I like that factoid. :) 4:25:19 PM - o]: it is pretty accurate 4:25:21 PM - megaTherion: but it missed the point as well 4:25:26 PM - megaTherion: C++98 has no lambdas 4:25:36 PM - o]: /j ##C++98 4:25:46 PM - minus: C++98 has no std::thread 4:25:50 PM - o]: :) 4:25:51 PM - mrbrklyn: reminds me of tux in the old perl irc channels 4:25:54 PM - megaTherion: indeed 4:25:56 PM - eraz: No lambdas? The horror! 4:26:06 PM - talisein [~talisein-at-april-fools/2013/sixth/talisein] entered the room. 4:26:17 PM - megaTherion: eraz: why... you can do a lot of good code with C++98, when people tried to enforce their C code on a C++ compiler back in the days 4:26:23 PM - blackbird1 [~blackbird-at-197.0.185.68] entered the room. 4:26:33 PM - blueness_ has left the room (Quit: blueness_). 4:26:34 PM - megaTherion: you can do very clean code with C++98 in fact, its great to know these things for a real life job 4:26:39 PM - ville [~ville-at-87-95-199-161.bb.dnainternet.fi] entered the room. 4:26:39 PM - eraz: megaTherion: But... but... lambdas!! 4:26:51 PM - o]: you can do clean C++98 code, but we don't have to 4:27:03 PM - o]: it is lots of boilerplate, which makes it more error prone and tedious 4:27:17 PM - o]: and no move, which forces the poor coder to create move functions. more boilershit 4:27:41 PM - mrbrklyn: there is a bias that newer is always better, which as you grow older, you relize that just isn't true at all 4:27:43 PM - eraz: oh right, no move semantics prior C++11... omg. 4:27:52 PM - megaTherion: eraz: just remembers me about a friend who just got his first job and leaving university, I told him begin with C++98 - learn the basics, he disagreed of course... one of the first task was looking at some C++98 code and no C++11 was available (some embedded platform /WinCE stuff) :) 4:27:56 PM - megaTherion: and thats just real life 4:28:07 PM - mrbrklyn: regardless, why can't the thread object take the implied this ? 4:28:08 PM - eraz: megaTherion: I know, I'm half-kidding here. :P 4:28:13 PM - eraz: I just like lambdas. :3 -- =
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|