« first day (320 days earlier)      last day (4614 days later) » 

11:01 PM
#3  0x00000000004268eb in (anonymous namespace)::generate (ch=...) at annex/unit/channel.cpp:55
55	        ch.push(i);
(gdb) p i
$1 = 6640927
That seems alright then!
 
Okay, so an std::future's destructor apparently get() which ends up as a join. So obvious deadlock here.
@RMartinhoFernandes Coinkidink, look how we're inside generate.
 
If I actually need to use an std::thread that I must detach I will feel silly :p
 
If you don't store the result of std::async, it gets destroyed at the semicolon, right?
 
11:05 PM
Yep
The program is hilarious.
 
Yeah, silly.
std::async isn't quite the exact equivalent of go after all.
 
I'm at 6427.
What happens if I have too many threads I wonder.
 
> In a multiprocessor system, memory ordering obeys causality
Wow.
 
@RMartinhoFernandes std::thread(functor, arg0, ...).detach(); is what I'm using.
Now at 10457
... That's a lot of threads isn't it?
 
Yeah.
The go equivalent does not use all that.
goroutines are not really threads.
More like fibers.
 
11:09 PM
Well, the implementations don't.
@RMartinhoFernandes Green threads, no?
 
@LucDanton Yeah, that.
 
That could be my next task actually.
Implement the same thing but as a boost::asio::io_service service.
Then blocking means reentering the io_service and rescheduling or something.
I used to have a thread pool implemented in terms of the C++0x threading primitives but since it's largely useless beyond trivial functional parallelism I delegated to io_service.
i.e. a task can then reschedule itself as long as it uses an Asio service or something, can't remember the terminology.
 
Which reminds me I haven't touched my BitTorrent code ever since I got to the parts that use Asio.
 
I've tried using 1.47 Asio with a move-only functor and it failed miserably :(
 
:( Move semantics will be important. I don't want to be copying large chunks of data all over the place.
 
11:17 PM
But I really don't understand why. I peered at the headers, checked the configuration macros, and as far as I could tell it was valid code.
Man, where can I get a C-ready table of primes.
I wish I understood the interface of OEIS.
Screw this I'm using Wolfram Alpha.
 
What do you want the primes for?
 
I'm making the sieve thing a unit test proper.
 
Ah.
Don't forget to make it terminate then :)
 
TIL the most expensive painting sold at public auction was sold for $106,000,000
what would you with a $106 mill?
 
11:23 PM
lol
 
A sandwich.
 
I'd probably waste it on books.
Buy my own library.
And hope I could buy the time to read them.
 
cool, books sound like fun :P
 
So I've got a line of comma-space separated primes. How do I format that for source code?
 
You mean, indentation and such aesthetic matters?
 
11:26 PM
s/(\w+, ){10}/ will capture but
@RMartinhoFernandes Yeah.
How do I refer to a repetition?
 
Nude, Green Leaves and Bust () is a 1932 painting by Pablo Picasso, featuring his mistress Marie-Thérèse Walter. The painting was in the personal collection of Los Angeles art collectors Sidney and Frances Brody for nearly six decades. It sold at auction for US$106.5 million, a world record price. It is currently on show at Tate Modern in London, alongside other Picasso paintings from the gallery's own collection. Background Nude, Green Leaves and Bust is one of a series of portraits that Picasso painted of his mistress and muse Marie-Thérèse Walter from 1932. The vibrant blue and li...
there it is
 
qq10f,i^M^[q10000@q
I'd do something like that.
 
Oooh recording, is it?
 
Yep.
Gosh, that looks like Perl.
 
What's the ^[? Does it stop recording or store it?
 
11:29 PM
It's Escape.
Start/stop recording is q.
 
Magic!!!1
Now I have 20 lines.
@RMartinhoFernandes I was trying to understand your incantation.
qq starts recording
 
Yes, on the q register.
 
I have no idea what f is but I did it 10 times and apparently I'm on the 10th comma.
 
It's "find".
 
Oh wait, 10f,
 
11:31 PM
f, moves to the next comma on the line.
 
Then i^M drops to insert mode and split on a new line
^[ I have no idea.
q stops recording
 
^[ is Escape, to go back to normal mode.
 
then repeat the sequence recorded inside buffer q 10000 times?
Oh okay.
 
@LucDanton Yes.
Adjust 10000 appropriately :)
 
Let's do that again but with a instead of i!
 
11:33 PM
Oh, yeah, i would break before the commas.
 
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
Ain't that neat?
 
q is my second favourite vim feature.
 
What's the correct one in English: 200 first primes, or 200th first primes?
 
@LucDanton 200. 200th is not a count.
 
i.e. is (200 first) the ordinal, or do I need (200th)
Oh that's a count then.
'first' has been needlessly confusing me then.
 
11:37 PM
Hello!
Quick check: any overload of placement-new has to return the argument, correct?
 
(I can see you're up to no good again :-) )
 
@KerrekSB No. It has to return a pointer.
 
@RMartinhoFernandes No, I want more, I want a guarantee that it has to be the no-op
That's true for the global placement new.
 
So wait.
 
11:38 PM
But is it also true for member placement new?
Because if I want to write an allocator, at some point I will have to construct the object via something like new (buf) T;.
 
You mean void* operator new(std::size_t, void* p);, not just any placement new.
 
Now if that last thing could be derailed by client overloads, I'd be stuck
Yes! The original placement-new. Indeed.
So according to Wikipedia, the global operators are not allowed to be modified.
But I was wondering about the member operators. You can certainly sneak some extra code into the operator, but I'm hoping that the return value is guaranteed to be the input argument, unchanged.
I certainly don't get a compiler warning if I violate that!
 
@KerrekSB I found that in the Standard.
 
@LucDanton Brilliant. I knew you would :-)
I was going to make a question, but then I thought, nah, this'll have a one-line Luc D answer ;-)
 
11:43 PM
Interestingly, GCC doesn't let me replace the global placement new, it says "error, previously defined". That's reassuring.
 
Isn't (the original) placement new a building block of the language?
I mean, you can't implement it in terms of something else.
 
What exactly does it say? Has to be precisely no-op, or just has to return the right value?
 
I do not see any 'special rule' for the void* placement new, user-defined or not.
 
@RMartinhoFernandes Indeed - you have to be allowed to write at least one type of new expression at some point in your life.
But any new expression invokes an operator-new.
 
You can do ::operator new(size, p); to bypass the class-wide operator new in any case, can't you?
 
11:46 PM
@LucDanton Yes yes, but how do you actually construct the object?
 
That doesn't construct the object...
 
The point is that there has to exist at least one safe new expression
 
operator new only allocates memory. The built-in placement new expression only calls a constructor.
 
I guess you could define global void* operator new(size_t, void * p, secret_type1, ..., secret_type213) throw() { return p; } that nobody can replace.
 
> If the new-expression begins with a unary :: operator, the allocation function’s name is looked up in the global scope.
::new (p) T(blah)
There you go.
 
11:47 PM
@LucDanton Really?? You can do that? Cool!
 
@LucDanton Neat.
 
So I guess user-defined, class-wide operator new's of the void* placement kind can do anything if there's this safeguard in place.
 
Yep - perfect
checks GCC's allocator implementation
(c++/4.6.1/ext/new_allocator.h)
  void
  construct(pointer __p, const _Tp& __val)
  { ::new((void *)__p) _Tp(__val); }
D'oh.
Could have discovered that myself :-(
They say people don't read enough anymore. What's really true is that people don't read enough code anymore.
I updated my insane auto container with ::new :-)
 
You still daren't use reinterpret_cast and still store the returned pointer :)
 
11:56 PM
@LucDanton Why...?
 
Well I just reimplemented boost::optional.
I just bit the bullet and I do a reinterpret_cast<T&>(storage); on the buffer.
 
@LucDanton Ah, is that what it does?
 
@KerrekSB No. But it does place an object on a buffer.
 
Oh, I see, to save the pointer member.
 
Right.
 
11:57 PM
Very green.
Do post it as a comment! :-)
 
Eco-friendly
Reduce reuse recyle
 
The cast is unspecified if T doesn't have standard layout. (Yes, I know it works on all implementations.)
 
@RMartinhoFernandes Just isolated a bug thanks to your stress test.
Forgot to notify the other end when closing the channel :|
 
@LucDanton It's not really "mine", I just converted the code from the Go spec to your API, which matched very nicely.
 
11:59 PM
Oh I know.
And they match due to the CSP inspiration.
 

« first day (320 days earlier)      last day (4614 days later) »