code logs -> 2020 -> Tue, 08 Sep 2020< code.20200907.log - code.20200909.log >
--- Log opened Tue Sep 08 00:00:17 2020
00:26 * McMartin considers being A Bad Person
00:26
<&McMartin>
I have a chunk of C++14-or-later code that I'm writing, and I have two ways to write it
00:27
<&McMartin>
One is with pointers all over in some ways that are tricky but traditional to reason about
00:27
<&McMartin>
The other is with std::shared_ptr<> which will be basically the same but "obviously" safer
00:27
<&McMartin>
And the final way is to make aggressive use of move constructors throughout the function and the lambdas it creates
00:28
<&McMartin>
I'm strongly tempted to do the latter just so that I can apologize for it in the code review with "I'm a little rusty with these data types"
00:46
<&McMartin>
Alas, now that I experiment with it, the third approach is in fact impossible, which makes std::shared_ptr<> the correct answer
00:46
<&McMartin>
(The need for move constructors is because some of the objects are noncopyable, but other parts of the underlying code need everything passed in to be copyable.)
00:55
< catalyst>
ahaha
00:55
< catalyst>
shared_ptr is alright I guess
00:56
< catalyst>
does it really need to be shared though? can it just be unique in the owning frame and then passed by reference?
00:56
< catalyst>
oh, lambdas
00:56
< catalyst>
nevermind
00:58
<&McMartin>
Yeah, it's a capture and the resulting function object is apparently copied by the underlying library, so capturing noncopyables (like, whoops, unique_ptr) is contraindicated
00:58
<&McMartin>
I could teeeeechnically use a raw pointer here and do a delete within the lambda at the end but I'm thinking "you know what maybe no"
00:58
< catalyst>
you know what would be really good for these kind of circumstances
00:59
<&McMartin>
Lifetimes built into the underlying system?
00:59
<&McMartin>
(Actually I'm not sure where you're going with this please proceed)
00:59
< catalyst>
also yes that sounds like the kind of optimisation that would make me cry, and if performance is a concern there then idk, write a better algorithm
01:00
< catalyst>
oh I was just going to say something throwaway about lifetimes
01:00
<&McMartin>
Yeah
01:00
<&McMartin>
Now, one option would be to dig deeper into this so that the lambdas *can* be noncopyable and everything still works
01:00
< catalyst>
rust impresses me because it casually provides a safe, single threaded shared pointer type
01:01
< catalyst>
and in implementing that in C++ I decided it would be impossible
01:01
<&McMartin>
But right now I'm trying to unfuck some unit tests so that I can implement better analytics on whether or not the system is being overtaxed or underutilized
01:01
< catalyst>
well, incredibly unwise at least
01:01
< catalyst>
honestly I would just go with the shared_ptr
01:01
<&McMartin>
And then after I have that as a baseline then I could look into "hey, maybe moves everywhere?"
01:01
<&McMartin>
Yeah, shared_ptr is 100% what I need *right now*
01:02
<&McMartin>
But we get to have C++17 here, so between mandatory RVO and move captures/initializer captures the move-based one looked way cleaner :(
01:02
< catalyst>
it's also not slow to access, only slow on copy and deallocation
01:02
< catalyst>
:<
01:02
<&McMartin>
No need for me to be coy though, I guess
01:03
<&McMartin>
It's a std::promise, it is not doing a whole lot in the first place and it's not somtehing happening thousands of times a frame
01:03
<&McMartin>
But it also means "hey, this is explicitly for crossthread synchro"
01:03
< catalyst>
sounds like you might have already overthought it I guess
01:04
<&McMartin>
But yeah, I was hoping for "declare promise auto, save its future in an auto, move the promise into a lambda that sets its value, RVO-return the future to original thread"
01:04
<&McMartin>
Yeah, Friday was spent fencing with two of the more senior guys about what needed to be done in broad terms
01:04
< catalyst>
I'm already seeing sadness in my future over going back to C++
01:05
< catalyst>
so much of this is just simple standard types and compiler stuff in Rust
01:05
<&McMartin>
I'm definitely in that new-hire phase where I walk in with the attitude that everything will appear to be horrible and dysfunctional, and I'll be set to adapt and extend
01:06
<&McMartin>
So far I've found a number of pretty ugly bugs and seen the scars of some design battles
01:06
<&McMartin>
And tbh it's also nice to see a response to "here is my perfect geometric logic that shows that moving this one line fixes the race condition" is pretty overwhelming "no, use sledgehammer plz"
01:07
<&McMartin>
But yeah, from what I've seen so far... if this were Rust, we'd be having to use Arc<> and friends, not just Rc<>.
01:13
< catalyst>
x)
01:15
< catalyst>
pretty much, though Arc is essentially shared_ptr I suppose, to the point where i recognised the various tradeoffs in its design matching
01:16
< catalyst>
it's more the idiomatic nature of the language supporting it rather than giving you a bunch of get outs that will just break when you look at it from the wrong place
01:17
<&McMartin>
Yeah
01:17
<&McMartin>
It's more "if this had been in Rust in the first place, there's a good chance that the move-based approach would have just worked"
01:18
< catalyst>
aye
01:18
< catalyst>
it certainly has a much stronger idea of lifetimes via lambdas
01:19
< catalyst>
or at least that's my impression
01:30 himi [sjjf@Nightstar-1drtbs.anu.edu.au] has joined #code
01:30 mode/#code [+o himi] by ChanServ
01:39 Kindamoody is now known as Kindamoody[zZz]
01:45 Pink [user1@Nightstar-g7hdo5.dyn.optonline.net] has joined #code
01:46 Pinkhair [user1@Nightstar-g7hdo5.dyn.optonline.net] has quit [Ping timeout: 121 seconds]
01:48 Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection closed]
02:17
< catalyst>
I am feeling very competent
02:17
< catalyst>
that's kind of new, honestly
02:18
< catalyst>
I know I always was but I don't think I've ever felt so innately like I know what I'm talking about
03:03
<&McMartin>
Yay, whatever the opposite of imposter syndrome is
03:03
<&McMartin>
... poster-girl syndrome?
03:04
< Mahal>
Ahah
03:04
< Mahal>
I like that
04:30 Degi [Degi@Nightstar-pkig1n.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
04:31 Degi [Degi@Nightstar-dd9i1i.dyn.telefonica.de] has joined #code
05:14 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has quit [Connection closed]
05:14 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has joined #code
05:14 mode/#code [+ao VirusJTG VirusJTG] by ChanServ
05:50 Vorntastic [uid293981@Nightstar-ks9.9ff.184.192.IP] has joined #code
05:50 mode/#code [+qo Vorntastic Vorntastic] by ChanServ
06:01 celticminstrel [celticminst@Nightstar-8kptuo.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
06:01 celticminstrel [celticminst@Nightstar-8kptuo.dsl.bell.ca] has joined #code
06:01 mode/#code [+o celticminstrel] by ChanServ
06:03 celticminstrel [celticminst@Nightstar-8kptuo.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
07:42 himi [sjjf@Nightstar-1drtbs.anu.edu.au] has quit [Connection closed]
09:23 Kindamoody[zZz] is now known as Kindamoody
09:31 Emmy [Emmy@Nightstar-l49opt.fixed.kpn.net] has joined #code
09:38 Emmy [Emmy@Nightstar-l49opt.fixed.kpn.net] has quit [Ping timeout: 121 seconds]
10:27 himi [sjjf@Nightstar-v37cpe.internode.on.net] has joined #code
10:27 mode/#code [+o himi] by ChanServ
10:49 catalyst_ [catalyst@Nightstar-vsirs3.dab.02.net] has joined #code
10:51 catalyst [catalyst@Nightstar-v6lb30.cable.virginm.net] has quit [Connection reset by peer]
10:51 catalyst [catalyst@Nightstar-v6lb30.cable.virginm.net] has joined #code
10:53 catalyst_ [catalyst@Nightstar-vsirs3.dab.02.net] has quit [Ping timeout: 121 seconds]
11:30 JustLurk [justbob@ServerAdministrator.Nightstar.Net] has joined #code
11:30 JustBob [justbob@Nightstar.Customer.Dissatisfaction.Administrator] has quit [NickServ (RECOVER command used by JustLurk)]
11:30 JustLurk is now known as JustBob
11:30 mode/#code [+o JustBob] by ChanServ
11:49 Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has quit [[NS] Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
11:50 Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has joined #code
11:50 mode/#code [+o Reiv] by ChanServ
11:53 Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has quit [[NS] Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
11:53 Reiv [NSkiwiirc@Nightstar-ih0uis.global-gateway.net.nz] has joined #code
11:53 mode/#code [+o Reiv] by ChanServ
12:06 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has quit [[NS] Quit: Leaving]
13:35 celticminstrel [celticminst@Nightstar-8kptuo.dsl.bell.ca] has joined #code
13:35 mode/#code [+o celticminstrel] by ChanServ
15:15 Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has joined #code
15:15 mode/#code [+qo Vornicus Vornicus] by ChanServ
16:31 catalyst [catalyst@Nightstar-v6lb30.cable.virginm.net] has quit [Connection closed]
16:34 catalyst [catalyst@Nightstar-v6lb30.cable.virginm.net] has joined #code
17:11 Emmy [Emmy@Nightstar-l49opt.fixed.kpn.net] has joined #code
17:29 Vorntastic [uid293981@Nightstar-ks9.9ff.184.192.IP] has quit [[NS] Quit: Connection closed for inactivity]
21:47 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has joined #code
21:47 mode/#code [+ao VirusJTG VirusJTG] by ChanServ
22:49 himi [sjjf@Nightstar-v37cpe.internode.on.net] has quit [Ping timeout: 121 seconds]
23:29 Emmy [Emmy@Nightstar-l49opt.fixed.kpn.net] has quit [Ping timeout: 121 seconds]
--- Log closed Wed Sep 09 00:00:19 2020
code logs -> 2020 -> Tue, 08 Sep 2020< code.20200907.log - code.20200909.log >

[ Latest log file ]