« first day (1525 days earlier)      last day (3417 days later) » 

8:00 PM
@rightføld get_future and set_value are not thread-safe methods
4
 
user1804599
Also it depends on the implementation of Channel::receive and Channel::send.
 
user1804599
@StackedCrooked lol epic fail
 
@StackedCrooked interesting
 
packaged_task does not have this problem though
 
@LightnessRacesinOrbit if you can move the value_type of an iterator without any exceptions it'll turn the iterator into a move_iterator, otherwise it'll be a default iterator
@LightnessRacesinOrbit very useful when writing strong exception guarantee code
 
user1804599
8:00 PM
What is packaged_task?
 
@StackedCrooked rofl
 
@rightføld Bundles a promise/future/task
 
user1804599
What is a task?
 
> 30.6.4 [futures.state] says which functions are synchronised, promise::get_future() is not one of them.
@rightføld Anything callable.
 
user1804599
Hmm, this is kinda like a promise/future pair except it has a queue of completion handlers and can be completed multiple times. But it can be used in a similar way.
 
8:02 PM
...maybe set_value is thread-safe after all.
 
It needs to be
 
user1804599
@StackedCrooked I think that besides that my case is fine.
 
user1804599
The shared pointer is not destroyed until set_value returns.
 
COME ON TARS
 
user1804599
I still get "libc++abi.dylib: Pure virtual function called!" every few times I run my program.
 
8:08 PM
lol
 
Calling a virtual function in constructor/destructor can cause that.
Are you starting a thread in your constructor? And the thread calls virtual functions?
also, std::thread should be at the bottom of the list of member variables
 
Xeo
@CatPlusPlus Why? It wouldn't be completely unreasonable to expect a call to set_value to only happen in one thread for a particular promise
 
user1804599
@StackedCrooked I start at least std::thread::hardware_concurrency() + 1 threads in a constructor.
 
user1804599
Using boost::thread_group.
 
@Xeo It still needs to touch the same thing future touches
 
user1804599
8:12 PM
@StackedCrooked ok
 
Xeo
@CatPlusPlus Ah, I thought in the sense that multiple concurrent calls to set_value need to be safe
 
Well it follows from that really
 
user1804599
@StackedCrooked still happens
 
Check the backtrace
 
user1804599
ok
 
user1804599
8:15 PM
inb4 doesn't happen under debugger
 
user1804599
lol in debugger it just segfaults
 
Try putting a sleep at the end of your constructor and check if it now always crashes.
 
Install a top-level exception handler to get a trace outside of a debugger
 
user1804599
It's in the dtor of boost::asio::io_service.
 
Or just dump core or whatever
 
8:16 PM
TARS HURRY THE FUCK UP
 
user1804599
boost::asio::io_service must of course outlive the I/O thread.
 
user1804599
So I must put it after the threads in the class right?
 
-3
Q: are programs such as visual studio used by professionals?

R.v.Djust getting in to programming lately. Finding it quite fun. I'm quite a beginner, but I've managed to create a few programs my mom could use on her job so that's quite rewarding. But back to the question; So far I've been using C# in Visual Studio 2010. My question: do "professional" programmers...

 
A worker thread is probably calling .dispatch or .post on the io_service.
 
top kek
@LightnessRacesinOrbit wheely spinny move
 
8:17 PM
@rightføld BEFORE you sily
 
user1804599
@StackedCrooked yeah, four threads are writing files and one is running.
 
user1804599
@StackedCrooked So they are destructed bottom-up?
 
It's always the "ABBA" pattern.
struct Test { A a; B b; }; // A(), B(), ~B(), ~A()
 
user1804599
Ok.
 
user1804599
Is that guaranteed across public–private boundaries?
 
8:18 PM
@Rerito Which one?
 
Don't write multithreaded C++ programs if you don't know basic C++ semantics :v
 
struct Test : A, B {}; // also A(), B(), ~B(), ~A()
@rightføld Yes. (Or I quit.)
 
user1804599
Nice.
 
user1804599
I think the problem is that the threads are destroyed while .run() hasn't returned yet.
 
One way to enforce that A must outlive B is by requiring A& in the constructor of B.
 
8:21 PM
that does not enforce it in the slightest.
 
Ok, it only enforces the first half.
That A must be created before B.
 
> But back to the question
 
It only holds if A and B have "automatic" lifetime.
 
@StackedCrooked Doesn't enforce that either.
 
user1804599
Ok now I set a flag to indicate the VM is stopping, I stop the I/O service and I join all threads.
 
user1804599
8:26 PM
Let's see.
 
@Puppy You mean if they are on separate threads (thus separate stacks)?
 
@LightnessRacesinOrbit I'm amazed that your answer got +7.
 
no, I mean, there's nothing stopping anyone from passing in a reference to an unconstructed A object.
simple example is that there's nothing illegal about struct C { B b; A a; C() : b(a) {} };.
 
@CatPlusPlus Don't write multithreaded C++ programs, period.
 
Don't write C++ programs
 
8:28 PM
B would need to call a member or something on A to make it properly illegal.
 
@Puppy I suppose that correct. I don't really care though since that's a compiler error. (Unless you don't enable -Werror.)
 
could just use a pragma to turn the warning off for that constructor.
 
That would be sabotaging yourself.
 
Doctor it hurts when I hit myself what should I do
 
@CatPlusPlus Prescribe pain killers.
 
user1804599
8:31 PM
Deadlock. :(
 
@rightføld Can you show the code?
 
user1804599
It's quite a big thing, wait.
 
@FredOverflow What's the tl;dr?
The title seems farfetched.
Or well. I don't know what a plain thread is according to this guy's definition.
 
@Rapptz dunno, haven't watched it yet ;) just wanted to throw it into the room.
 
8:34 PM
Lame indeed.
 
Multuthreaded progs are easy if you a) Only create threads at app startup and b) Never attempt to terminate/destroy them until the OS does it at shutdown. I've been doing this in various languages for decades - no problems. As soon as you start continually creating/terminating/destroying threads, with join() shit or otherwise, it fucks up.
 
@CatPlusPlus hit other people instead
 
@MartinJames And also never share anything between them
 
@MartinJames I kinda agree, but not with your solution. It's true that manual thread management is as dumb as manual memory management, but I'd rather just apply a library that manages them correctly rather than just refuse to have threads that are managed.
 
@CatPlusPlus Yeah - apart from P-C queues, or the like.
@Puppy I don't need managed threads, (though I don't object to them if provided).
 
8:38 PM
@BartekBanachewicz Why?
It's good, expert advice.
Just because it's not what you wanted to hear doesn't mean other people aren't allowed to agree with its genius :)
 
@rightføld Haven't spotted the error yet. I'm not deeply familiar with io_service::stop though.
 
user1804599
Me neither, and the documentation isn't very good.
 
user1804599
I tried putting the work in an optional and resetting the optional in the dtor but it makes no difference.
 
SERIOUSLY TARS WE'RE ALL WAITING FOR YOU
 
@LightnessRacesinOrbit What are you talking about?
 
user1804599
8:40 PM
I could try while (run) { ioService.run_one(); }.
 
TYPICAL TARS
@Rapptz Hi there, and welcome to SO chat! You can click on the little arrow icons between the avatar and the message text in order to follow the message conversation back through replies. Hope this helps, and have a great day! :-)
 
@rightføld Can you run it in valgrind?
 
Nice arrow.
 
user1804599
@StackedCrooked No. I use Yosemite.
 
8:42 PM
1 min ago, by Lightness Races in Orbit
(http://music.stackexchange.com/a/26846/9524)
@Rapptz Well, you asked about my comments, which have arrows!
 
Also don't forget to specify copy/assign rules for your class.
 
preferably don't.
 
user1804599
If I don't join_all I don't get errors and it runs correctly, lol.
 
user1804599
But I'm afraid it could go wrong.
 
you can't know that it actually runs correctly.
it only appears to run correctly for now
 
8:44 PM
It's hard to avoid having a destructor.
So copy/assign must be done.
 
user1804599
@StackedCrooked can't copy.
 
user1804599
gc is non-copyable.
 
@StackedCrooked Delete them.
 
user1804599
Neither is fibers.
 
@Puppy That's what I meant.
 
8:45 PM
orite
 
@rightføld Seems like I said that earlier:)
 
user1804599
It doesn't deadlock out of debugger.
 
GCPtr(GCPtr<U>&& other) : ptr(other.ptr) { other.ptr = nullptr; }
GCPtr& operator=(GCPtr&&) = default; // shouldn't this also unset rhs.ptr?
 
no.
why would it?
the default is not defined in terms of move-and-swap.
 
8:48 PM
Oh, sorry.
 
user1804599
@StackedCrooked Yeah.
 
@StackedCrooked what is rhs?
 
user1804599
But that doesn't matter right now.
 
right-hand-side
 
user1804599
The destructor has no side-effects yet.
 
8:48 PM
it's not declared
 
user1804599
GC right now is just return GCPtr<T>(new T(std::forward<Args>(args)...));.
 
user1804599
I want to implement more important things first.
 
user1804599
Ohhhh I know what causes the deadlock.
 
user1804599
It's scheduledFibers.pop(fiber);.
 
8:50 PM
lol
I forgot about that.
 
user1804599
> Wakes up any threads that are waiting on the queue via the push and pop operations and raises the tbb::user_abort exception on those threads.
 
user1804599
Nice.
 
I usually unblock the queue by pushing a magic object into it inside my destructor.
 
user1804599
It werks!1!1
 
Magic object is either something that can be null or empty. Or a task that throws a "QuitException".
 
8:53 PM
welp
 
But that's because I suck.
 
just killed Jeb and lost 20% of my money by accidentally firing the parachute on the launch pad.
 
no revert mode is tough.
 
user1804599
Now I can get rid of run too.
 
8:54 PM
@rightføld widen the scope of the try block
 
user1804599
No, wtf.
 
user1804599
Try blocks should be as narrow as possible.
 
No it's the opposite.
 
user1804599
No.
 
user1804599
I am interested only in exceptions from this particular call, so the try block should contain only this particular call.
 
8:55 PM
hmm. chicken and black bean sauce?
 
You can handle the exception at top-level scope of your thread.
 
user1804599
Ah, I do need run.
 
Also try-catch in an inner loop is slow.
 
user1804599
@StackedCrooked No, that's retarded.
 
user1804599
It makes it completely unclear what I am trying to catch.
 
user1804599
8:56 PM
And I don't want to catch exceptions thrown by resume.
 
user1804599
@StackedCrooked idgaf
 
user1804599
Semantics first.
 
@StackedCrooked No, it really isn't, you failbucket.
 
A aborted exception should be something that propagates all the way to the top. It should not be caught inside an inner loop.
 
why not?
seems like he aborts from in the inner loop just fine.
 
user1804599
8:58 PM
I want to catch only exceptions thrown by scheduledFibers.pop(fiber);. Therefore the try block should contain and only contain scheduledFibers.pop(fiber);.
 
user1804599
If resume throws tbb::user_abort for whatever reason, I don't want to catch it.
 
Setting up the try block has a runtime cost afaik.
 
user1804599
Catching it would be a bug.
 
Good then.
 
@StackedCrooked Your k is wrong.
 
user1804599
9:01 PM
@StackedCrooked Negligible compared to pop and resume.
 
Sorry about that.
 
user1804599
resume can be extremely slow.
 
user1804599
I may want to add some preemption sooner or later.
 
@caps sucks
it's really good
 
9:02 PM
@LightnessRacesinOrbit Anywhere else I can listen to it?
 
user1804599
Currently I only yield fibers on channel operations.
 
OK
KSP on Hard is actually, well, pretty hard it seems.
 
@LightnessRacesinOrbit I got an even better "hat" \o/
 
@Borgleader nice
 
9:10 PM
@Puppy I can barely play easy... with mechjeb... and hyperedit...
 
user1804599
Well, time to implement signal handling and sending.
 
@LightnessRacesinOrbit I like it.
 
lol
> deleted by Jesper, Reimeus, Luiggi Mendoza 42 secs ago
 
user1804599
Blocking APIs are a pain.
 
user1804599
9:13 PM
I have to call them in a separate thread.
 
Someone voted to undelete.
Probably the OP.
 
user1804599
I thought of having e.g. extern fast sqrt: c.double -> c.double and extern slow kill: c.pid_t -> c.int -> c.int where the former would be called directly and the latter would be called on a different thread and communicate the result using a channel.
 
Meh - I opened my gob: "Well love, I thing we've got everything sorted for Christmas, I'll go make a brew". Go in kitchen, and the lamp above the worktops fails to stay up, cycling on the starter. Tomorrow, go get a 2 foot flourescent tube:(
 
@caps I get the same error. If I really wanted to, I could abuse my developer access to pretend I'm in England or something. But I won't.
 
@Mysticial So, you work for YouTube?
 
9:21 PM
@rightføld looks cool though
 
yeah
 
user1804599
@StackedCrooked which part?
 
The resume.
 
user1804599
Thanks.
 
user-level context switching is a neat idea
 
user1804599
9:22 PM
I can spawn 10000 fibers with little memory usage.
 
Non-locking APIs are a pain.
I have to design state-machines with callbacks.
 
I already killed two pilots lol
 
user1804599
Spawning 10000 threads requires a lot of memory.
 
yesterday, by caps
@LightnessRacesinOrbit True. Maybe soon Google will roll out "Video" and do the same thing to YouTube that Inbox is doing to Gmail.
 
third one eager to join
 
9:23 PM
Can you tell us if anything like that is on the way?
 
user1804599
And writing async I/O code manually is a PITA.
 
I almost cut myself with a screwdriver
I blame Robot
 
user1804599
Emo.
 
@rightføld Your fibers are stackless?
 
user1804599
They keep their own stack which grows as necessary.
 
user1804599
9:25 PM
Not the pthreads call stack.
 
@Mysticial Can you do that with only 33 rep?
 
You can always vote to delete/undelete on your own question. (unless it's mod deleted/locked)
 
// might want a helper like this
auto pop_stack = [&]{
    auto result = fiber.evaluationStack.back();
    fiber.evaluationStack.pop_back();
    return result;
};
 
user1804599
Yeah. :P
 
9:32 PM
If you position TailCall above Call then you could use a fallthrough instead of goto.
 
user1804599
Heh.
 
right
time to kill pilot #3
 
user1804599
More fragile.
 
Alright then.
 
user1804599
goto is explicit, fallthrough isn't.
 
9:34 PM
Just thought it would look nice to have Tailcall on top of Call since it
kinda represents the flow.
 
user1804599
Also: fallthrough won't work.
 
user1804599
Look closely at the definition of OPCODE.
 
welp he died.
holy fuck it's hard to control these solid fuel engines.
 
user1804599
It increments the instruction pointer before the label.
 
Check out CKAN for mod management
 
user1804599
9:35 PM
Using a fallthrough would thus increment the instruction pointer twice.
 
user1804599
Which is not just wrong, but may result in UB because the call stack may be empty.
 
forgot to add a parachute to his command pod.
 
@Puppy you are horrible
 
normally I'd just revert to VAB
 
Xeo
Good thing he's not working for NASA.
or SpaceX
 
9:41 PM
...but VAB blew up too? :V
 
Xeo
lol
 
Obama is disappoint in Sony.
 
Fuck autoplaying videos
 
+1 for creativity in initializers. Tempted to come with a UDL that allows to write dates in this way: 2014-12-19_d. Entirely feasible in c++11 — sehe 7 secs ago
@StackedCrooked He can easily terrorize them back into releasing it. US govt. has the weapons that hurt - da monies
 
+1for the +1font
 
9:50 PM
@Puppy who?
 
@sehe My pilot.
 
I find it hard to believe that NK is not aware of the Streisand effect.
 
@Puppy Is he a real thing
@StackedCrooked ∓1 for spacing
 
no, he was a Jeb.
 
@StackedCrooked Which is why she isn't in that movie DPRK isn't behind it
 
9:52 PM
NK doesn't seem to be aware, no
 
@caps great innit
 
@StackedCrooked I completely agree with him.
Not something I usually say about the guy.
 
user1804599
> The Interview is a 2014 American political action comedy film directed by Evan Goldberg and Seth Rogen, and written by Dan Sterling.
 
user1804599
Sounds fun.
 
@rightføld I wouldn't not have known about this movie if it wasn't for NK's advertising.
 
10:00 PM
me too
 
@StackedCrooked I would not even have wanted to see it if not for NK's advertising.
 
still, a movie about graphically assassinating a foreign leader is pretty inflammatory
"free speech" only gets you so far. The movie was a silly idea.
 
"it would take me days to write the code" - Stop being so dramatic. C++ is not Python, accept it and move on. — Captain Obvlious 4 mins ago
Is it me or CaptainObvlious has been really (passive) agressive lately?
 
By default, boost::bind returns function objects that drop all the parameters that were not bound in some way. Is it possible to get the opposite functionality?
 
user1804599
> A few months from now North Korea is going to release a movie that has two people interviewing Obama.
 
user1804599
10:05 PM
lol
 
Whereby with signature S1 void (SomeClass, OtherClass&, double, int) I could use boost::bind to get a signature S2 void (double, int) without specifying any bindings other than the ones for SomeClass, OtherrClass&?
 
Quick quiz question.
 
Is there already a StackOverflow question about this or should I write one?
 
Is this valid syntax, and how confident are you about your answer?:
auto x = unsigned int();
 
I can't find one.
@StackedCrooked Um... it doesn't look valid to me. But I'm still pretty noobish, I feel like.
 
10:08 PM
I myself didn't know and had to try it out.
 
user1804599
@StackedCrooked Yes. 100%.
 
I was 60% sure that the syntax was valid.
 
@sehe this is your area of expertise, right?
 
@caps what is, friend?
 
user1804599
 
10:10 PM
@sehe boost
See my messages just above.
 
I don't see the context.
 
@rightføld she was not pleased :P
 
@caps void foo(int); boost::bind(f, _5) IIRC
 
@sehe I mean... generically.
I am writing a "simple" proof of concept for a template class.
 
6
A: Opposite of std::bind, add dummy parameters to function

seheEdit Oh, I mentioned the obvious in chat: @EthanSteinberg: lambdas? [] (int realparam, int dummy) { return foo(realparam); } But it was dismissed, which is why I jump to: Edit I just realized a much simpler approach: http://ideone.com/pPWZk #include <iostream> #include <functional> usi...

 
10:14 PM
With a private boost::function member_function object and a public boost::function PubliclyCallableFunction that will have the same signature as member_function EXCEPT the first two parameters of member_function will be bound to member values of the template class.
@sehe Thanks, I'll have a look.
@sehe Should this work in C++03 with Boost 1.39?
 
Yes
 
Xeo
@sehe I like how the (_1, _2) doesn't add anything over the other call :D
 
user1804599
And then he hates it!
 
@sehe Okay. I see how this works. It adds dummy parameters to the signature. They're not used by the function. That's not exactly what I'm looking for, but that is probably because I haven't states my question clearly enough.
building off of this:
5 mins ago, by caps
With a private boost::function member_function object and a public boost::function PubliclyCallableFunction that will have the same signature as member_function EXCEPT the first two parameters of member_function will be bound to member values of the template class.
member_function has some templated signature, say, S.
PubliclyCallableFunction will have the same templated signature, except that the first two parameters will not be there, because they will be bound.
so if member_function has a signature of void (T, F, int, double) then PubliclyCallableFunction will have a signature of void (int, double. But if member_function has a signature of void(T, F, std;:string, float, int, SomeClass&), then PubliclyCallableFunciton will have a signature of void(std;:string, float, int, SomeClass&)
Unless I am misunderstanding the link you shared (which is possible), that is something a little different.
 
10:23 PM
I was wrong: operator precedence require to write 2014-(12-18_d). That's sad. Now we can't have better than 2014_y-12-18 I think. — sehe 5 secs ago
 
In other words, I want to use boost::bind like PubliclyCallableFunction = boost::bind(member_function, memberOfTypeT, memberOfTypeF, /*infer that all other parameters are always passed through*/)
Is there a question already dealing with this somewhere, or should I write one?
 
@rightføld wise lions know to wait for the meat to grow?
 
Xeo
@sehe Ew. I'd want it as 2014_y-12_m-18_d anyways.
just to make it clear
 
@sehe sorry, I keep hitting enter. Should I take your silence to mean the question you shared answers my issue and I should read over it some more?
 
@Xeo lol. The point is. You don't want this anyway!
 
user1804599
10:30 PM
@sehe Not in America!
 
user1804599
I may get Programming in Go by Mark Summerfield.
 
so then
this is the last flight of Dead Space Program, or I'll lose the game.
wish me luck
 
user1804599
bad luck
 
looks like I made it
got enough Funds for a couple more launches
holy fuck shoulda brought a Goo.
 
@caps must it be c++03? In that case, not much more option than to specialize a functor for N arities. You can do it without bind or with bind. It's basically the same effort (so I'd do without it). I'm not aware of an existing question about this. But in general, people have been generically reflecting function prototypes far too often, so I bet it exists.
 
10:40 PM
@Xeo I think it should be 2014_y+12_m+18_d
 
Xeo
12 mins ago, by sehe
@Xeo lol. The point is. You don't want this anyway!
;)
 
Yeah. This is why it sucks
 
@sehe Unfortunately, until Embarcadero gets their act together I am stuck in C++03.
 
I don't judge
 
@sehe Hm, what would such a specialization look like? Would it be easier (easier on my brain, that is) to create a separate template class for each possible (reasonable) number of parameters in S?
 
10:43 PM
That's what I mean
 
@sehe Ah, you said a functor. One of us is misunderstanding the other for sure.
 
If you insist
 
@sehe It's probably me. :)
 
TARS FOR GOD'S SAKE
 
10:48 PM
@sehe so, this would mean that PubliclyCallableFunction is of a custom functor type that I would define? That infers how many parameters are in member_function and then passes them all through, maybe with bind, maybe with out?
 
Yes
 
How do you do a dynamic cast of unique_ptr? I wrote a program using raw pointers and I want to change it to unique_ptr and I've done everything except for how to replace "dynamic_cast <derivedclass >(baseclass)".
 
no.
 
Xeo
auto* p = dynamic_cast<derived_class*>(base_p.get());
 
Now that would be insane :P
 
user1804599
10:53 PM
You can move-constructor or move-assign unique_ptr<base> from unique_ptr<derived>.
 
user1804599
But not the other way around AFAIK.
 
@TriHard8 There's a whole site for this crap:
23
Q: Dynamic casting for unique_ptr

betabandidoAs it was the case in Boost, C++11 provides some functions for casting shared_ptr: std::static_pointer_cast std::dynamic_pointer_cast std::const_pointer_cast I am wondering, however, why there are no equivalents functions for unique_ptr. Consider the following simple example: class A { virtu...

So, TriHarder
 
Haha, I've been reading that. He's referring to the move functions in there, so my situation was slightly different...
 
Okay, I gotta open this can of worms...I need help determining "best" practice here.
I'm rebuilding a project from ActionScript to C++, and thus, rethinking some OOP aspects.
I have a base class, Person, from which I'll be deriving students, providers (tutors), and instructors. However, it is possible to have a student who is a tutor, and an instructor who is a tutor.
My first thought is that a single object could be from two different classes, but that doens't sound right. What's the best approach here?
 
Peeps. You don't need to do anything such thing. The lounge is for lounging.
Please keep Q&A at Stack Overflow
 
10:57 PM
(I ask here because this is entirely too subjective to post as a regular Q.)
 
"Lounging" is relative. Some people like talking about this stuff.
 
It's not on Programmers or perhaps CS. And regardless, it has been asked a zillion times
@TriHard8 Teehee. Nope. Lurk around more.
Some people here like discussing library proposals, TMP conundrums, Haskell evolution, etc.
 
user1804599
 
user1804599
> I'm gonna show you all corners of the bedroom.
 
But most of us do not (I repeat not) enjoy another inheritence vs. composition yawn debate
 

« first day (1525 days earlier)      last day (3417 days later) »