« first day (236 days earlier)      last day (4715 days later) » 

5:00 PM
Does anyone feel like reviewing some of my code?
 
@StackedCrooked I feel like rewriting code all the time.
 
If it has defects I can point :D
Hmm, what's an evil grin smiley?
 
@FredOverflow I've felt that temptation a lot today at work. It's a, eh, less-than-perfect codebase :)
 
The alternative is to write "hello world" programs from scratch :)
I don't think it's possible to write large systems without the occasional rewrite of some components.
 
5:03 PM
It's a few utility classes for threading. Feel free to destroy it with your criticism: code.google.com/p/tetris-challenge/source/browse/trunk/Main/…
 
People rarely start from scratch. That's one reason why C++ still matters today.
@StackedCrooked I'm no expert on C++ threading, sorry.
And why would you need threading for Tetris, anyway? Networking? Sound?
// Lock/Unlock function. These could be overloaded for different mutex types.
// ...or you could just replace them with function templates :-)

template <typename Mutex>
void lock(Mutex& mutex) { mutex.lock(); }

template <typename Mutex>
void unlock(Mutex& mutex) { mutex.unlock(); }
 
@StackedCrooked Why does ThreadSafe::Impl not hold by value?
 
@FredOverflow Tetris was used as a testing ground. I wanted to create an AI that can process a big search tree concurrently. But this code is not limited to Tetris.
 
@StackedCrooked Ah, parallel AI. That sounds really useful.
 
@FredOverflow Why do you use a pimpl and put it in the header?
 
5:08 PM
@LucDanton To enable shared ownership basically.
 
Or am I misunderstanding it completely?
 
@MartinhoFernandes I don't see any pimpl there, what are you talking about? Also, it's not my code.
 
@MartinhoFernandes I'm not using pimpl ideom here. The ThreadSafe::Impl is simply a class that bundles the object with a mutex. Perhaps I should rename it to avoid confusion.
 
@StackedCrooked I've been having the same feeling today that I decided to apply some of the stuff Uncle Bob mentioned in Clean Code to C++
Needless to say the outcome was horrifying.
 
@FredOverflow sorry, my mouse misfired :) Seems like I am misundertanding :(
 
5:09 PM
@StackedCrooked But a ThreadSafe::Impl shares nothing with noone. It holds (and owns) a bare pointer when it could hold by value
 
@KhaledNassar Like what?
 
bool compare(const ThreadSafe<Variable> & inOther)
    { return mImpl.get() < inOther.mImpl.get(); }
This is UB
 
@FredOverflow The DTO stuff
 
rlc
what is LockMany for?
 
You probably wanted mImpl < inOther.mImpl
 
5:10 PM
By the way I was kinda surprised when I found out I can call member functions in C++ that are declared later in the file. Anyone else had the same experience?
 
@LucDanton Why is it UB?
 
@KhaledNassar What is DTO?
 
Data Transfer Object
 
@rlc SBRM wrapper for mutexes?
@StackedCrooked Undefined Behaviour.
 
@rlc I found a need for a LockMany class in the WorkerPool class.
 
@MartinhoFernandes I know, but "why" was the question :)
 
@KhaledNassar What is that? Passing one object with 10 data members instead of passing 10 parameters?
 
@StackedCrooked Because unless you're doing something extremely funky they're not going to be pointers inside the same array
You cannot compare two pointers of two different objects without invoking UB (different here means not in the same array)
 
@StackedCrooked Ok. Seems like I gotta sleep.
Bye.
 
rlc
@MartinhoFernandes SBRM doesn't make a lot of sense on mutexes, and LockMany doesn't own the mutexes AFAICT
 
5:12 PM
@LucDanton We have a question on SO for that, let me search...
 
rlc
@StackedCrooked does it guarantee consistent locking order?
 
@FredOverflow Basically separating business objects from database records using a "man-in-the-middle" object.
 
@LucDanton What?
 
@FredOverflow In a sense, pretty much what you said. :)
 
rlc
I don't see how..
 
5:13 PM
int i; int j; &i < &j; is UB
 
@LucDanton int*?
 
int i[2]; &i[0] < &i[1]; is fine
 
@rlc No. The purpose was originally that it would check at runtime if it does, but it doesn't do anything like that now.
 
rlc
it does guarantee consistent unlocking order, but that doesn't help much..
 
9
Q: checking if pointer points within an array

FredOverflowCan I check whether or not a given pointer points to an object within an array, specified by its bounds? template <typename T> bool points_within_array(T* p, T* begin, T* end) { return begin <= p && p < end; } Or do the pointer comparisons invoke undefined behavior if p...

 
5:13 PM
@CatPlusPlus Thanks
 
rlc
@StackedCrooked how does the work pool use it?
 
@LucDanton But that would mean that std::set<MyClass*> is also UB? (Because it compares pointers..)
 
@StackedCrooked It uses std::less<T*> which is specified to be fine
 
@rlc Check the WorkerPool::interruptRange method for an example: code.google.com/p/tetris-challenge/source/browse/trunk/Main/…
 
boost::shared_ptr is documented to have a working operator<, too (supposedly it uses std::less behind the covers)
 
rlc
5:17 PM
@StackedCrooked lock the queues of all the workers in whatever order those workers happen to be and hope for the best..
 
C, as in C the international Standard, is not, in fact, a portable assembler and pointers are not, in fact, addresses but a high level concept. For a C++ programmer it probably helps to consider them as either a handle to an object where the only operations available are assigning or dereferencing, maybe deleting or an iterator inside a raw array, but not both.
 
Is that a quote?
 
@rlc What do you mean with "hope for the best"?
 
@FredOverflow It's just me
 
Does Boost have any higher-level concurrency building blocks than threads?
 
rlc
5:19 PM
@StackedCrooked well, I don't know if WorkerPool is supposed to be thread-safe, but I wonder how it's supposed to act with resize and interruptRange being called concurrently if it is supposed to be thread-safe..?
 
@FredOverflow boost::future and boost::promise. Not sure if a combination of boost::asio and boost::thread_pool counts as well for your purposes.
 
@rlc You mean that there is danger of inconsistent lock ordering? That's not the issue here. Btw, I've got fairly intensive unit tests for this particular class: code.google.com/p/tetris-challenge/source/browse/trunk/Main/…
 
rlc
@StackedCrooked no, not lock ordering - lock ordering looks fine
 
@LucDanton Ah, std::future and std::promise originate from Boost, didn't know that.
 
@FredOverflow They're somewhat recent. I don't really know which one influenced which.
 
rlc
5:21 PM
if resize gets called somewhere beyween lines 87 and 100, some workers may or may not be locked when they get called - and some workers may or may not exist
 
@rlc Aah I see. Well, "interruptRange" is a private method. The calling methods like "resize" take care of locking the mutex.
 
rlc
OK (I haven't seen the header yet)
 
@LucDanton Concurrency is a nice reality check. Every time I think I know almost everything there is to know about programming, I remind myself that I know almost nothing about concurrency :)
2
(plus the other paradigms, of course)
 
@FredOverflow That should be a quote.
 
rlc
5:26 PM
@StackedCrooked ok, that looks fine then :-)
 
@rlc cool :)
 
@KhaledNassar Well, you can quote me if you want:
2 mins ago, by FredOverflow
@LucDanton Concurrency is a nice reality check. Every time I think I know almost everything there is to know about programming, I remind myself that I know almost nothing about concurrency :)
;-)
 
:836578 std::less is defined as:
template <class T> struct less : binary_function <T,T,bool> {
  bool operator() (const T& x, const T& y) const
    {return x<y;}
};
 
What is that, a standard quote? Or just some source code from your standard library implementation?
 
Why is std::less<T*> is defined behavior, and T* < T* not, when dealing with unrelated objects?
 
5:30 PM
@StackedCrooked Because the standard says so.
@StackedCrooked That reference is clearly wrong.
Don't blindly trust C++ resources on the Internet!
 
That's not that wrong, it's correct for non-pointer types.
 
@FredOverflow I thought cplusplus.com was a good reference.
 
@StackedCrooked Is it really useful that LockMany has a getter to any mutex it holds?
 
@StackedCrooked Who gave you that idea?
 
@LucDanton No it's not. Actually that is a bad thing. Going to delete that right now.
@FredOverflow I think here. Let me see if I can search history of this chat.
 
5:34 PM
@StackedCrooked All in all I don't have much to say about the design/correctness. I'm not that familiar with the Boost locks but I do believe you're doing it right with the upgrading and so on.
 
Personally, I look standard library matters up in the standard. You can mostly trust the standard :)
 
I don't like the shared ownership but that's a personal matter
Out of curiosity, the policies are supposed to make is easy to add new functionality but are not directly intended to be features for the user, right?
 
Hm, this site also documents C++0x library features. Is it any good?
 
@LucDanton The getters would make it possible for outsiders to unlock one of the held mutexes. That's bad IMO. And may lead to double unlocking later on.
 
@StackedCrooked I'm speaking for the code as a whole right now
 
5:37 PM
@LucDanton Ah I see. Cool! Thanks.
 
@FredOverflow Are you looking for a nice reference of the C++0x threading facilities?
@StackedCrooked I have to say though, my biggest peeve with the code is the triple indirection cost of ThreadSafe::Impl
 
@LucDanton The policies may be used by the users if they really want to.
 
@StackedCrooked But they are not accessible from ScopedAccessor and the like
 
@LucDanton Perhaps that is somewhat wasteful. I'll see if I can fix it.
@LucDanton You're right about that. It's an aspect that isn't really thought out right now.
 
I'd suggest using a boost::shared_ptr<Impl> where Impl stores by val (moral equivalent of tuple<Variable, SharedMutex>)
That's okay, it's not bad. It makes it a very nice maintenance point.
Finally if you use boost::make_shared you get to pay only one indirection.
 
5:43 PM
@LucDanton I finally see what you mean here! Indeed it makes no sense :D
 
All that remains to be said is how often do you need to share a variable between threads, anyway?
 
Unfortunately boost::shared_mutex is noncopyable..
@LucDanton Well I created a project that uses multithreading extensively for the purpose of learning multithreading.
 
@LucDanton I'm not looking for anything, just wondering if there is such a thing as a good C++ online reference.
 
Xeo
@FredOverflow stackoverflow.com
:)
 
@FredOverflow Apparently I got the idea here: chat.stackoverflow.com/transcript/10?m=735771#735771
@FredOverflow and remembered it incorrectly!
 
5:58 PM
Oh boy, last week's South Park episode is so good...
> Due to pre-existing Contractual Obligations, we cannot stream this episode until 07.01.2011
LOL?
 
@FredOverflow City Sushi?
 
@KhaledNassar Yes
 
@LucDanton At least I got that fixed :) (code.google.com/p/tetris-challenge/source/…)
 
How long do I have to wait for January 7th? :-)
 
6:00 PM
First of July, actually.
Episodes are available for watching a month after air date.
 
Ah, of course. First the month, then the day. It's different in Germany.
 
In some regions...
 
> ....Did we just watch the last episode of South Park?
http://www.reddit.com/r/reddit.com/comments/hv65u/did_we_just_watch_the_last_episode_of_south_park/
 
The current episode was kinda strange...
@StackedCrooked You can't have multi-line quotes.
 
@FredOverflow The second line was not even a quote :(
 
6:05 PM
> I hope it turns out that Terrance and Philip were never about fart jokes but rather it was was just the viewer's interpretation because the viewer is too old too appreciate what appeals to the kids. I think south park just blew my mind.
lol
 
> Helgrind builds a directed graph indicating the order in which locks have been acquired in the past. When a thread acquires a new lock, the graph is updated, and then checked to see if it now contains a cycle. The presence of a cycle indicates a potential deadlock involving the locks in the cycle.
This is interesting. I could use this idea to implement a runtime lock order checker..
 
 
1 hour later…
Thanks :)
 
7:55 PM
Hm, quite boring so far. I prefer technical talks.
 
8:43 PM
Was it mentioned that BoostCon videos are starting to be available?
 
Xeo
Zap. Finally finished with my shader exam.
Though, finished can not really be said.
Rather, overdid it.
 
0
Q: when i send and convert std string with win32 SendMessage im getting wired characters

user63898I need to append text to win32 edit control i have working function to do this , but the text that printed in the edit control is gibrish why ? the sample code taken from microsoft example from here void settext(HWND hDlg,std::string s) { //std::wstring ws; //ws.assign( s.begin(), s.en...

anybody know what the problem is? I think it's the fact he's passing a std::string instead of a wstring, but I could be wrong
 
@Xeo Tss, you should really make an effort to stop overdoing things!
 
not sure what the win32 api's string encoding is
 
@TonyTheTiger Unicode 16-bit
 
Xeo
8:46 PM
@TonyTheTiger Depends on your project settings
 
@TonyTheTiger or "MultiByte..." depending on your VS option
 
Xeo
@StackedCrooked I'm so sorry. Our assignment was to implement conway's game of life in HLSL pixel shader
 
@LucDanton links please
 
@Xeo Game of Life is addicting by itself.
 
Xeo
My implementation can now parse and use any of the rules mentioned here :(
 
8:47 PM
I would like to create a generator that is able to find the most minimal and yet longest living life forms.
 
BoostCon videos available here. It's not just BoostCon 2011 so take note of the release date of each video.
 
@StackedCrooked can a std::string deal with that?
 
@TonyTheTiger Uni16 requires std::wstring. However, I recommend a different approach.
 
Xeo
Did I yet mention I hate those all-uppercase typedefs from windows?
 
@StackedCrooked oh
 
8:50 PM
@TonyTheTiger I would always use std::string (UTF8 encoding), and then when interfacing with a Win32 call locally convert it to uni16 first. The opposite order of actions when getting a string from the WinAPI.
From my XULWin project :D
@Xeo typedefs? Macros more likely :/
I hate that on Windows I can't use the std::min and std:max functions because they have been defined by Windows (as lowercase!)
 
Xeo
@StackedCrooked #define NO_MIN_MAX or sth like that
directly before including any windows header
 
@Xeo Yeah, I know, but that's a burden :)
 
Hey all
 
Xeo
Anyways, I'm off for today. Been awake for way too long already.
g'night everyone
 
I am having a floating issue in IE 8. The divs involved are the following:

#wrapper div 980px

#main div 698px
25px padding on left and right

so 698 + 25 + 25 = 748px

#panel div width 230px and border left and right 1px
so 230 + 1 + 1 = 232px

748 + 232 = 980px

which is the width of the wrapper

This works fine on Google Chrome, Firefox, and Safari.

However, on IE 8
it drops below on one page
 
8:55 PM
@Xeo g'night!
 
and then on another there is a gap between the two divs
 
@LucDanton Oh, something about Haskell, nice!
> Sorry, this episode may have just been added to blip.tv and isn't quite ready to watch yet. Please try again later.
:-(
 
Let me dig deeper
 
Oh well, Arnold Schwarzenegger's talk about "Threads and Shared Variables in C++0x" will also be an interesting watch.
 
@FredOverflow Welp, nothing to do but wait. The video has been uploaded a few hours ago.
 
9:07 PM
@LucDanton I'm a C++ programmer, I don't like waiting :)
 
@FredOverflow Are you saying that you're doing video-watching-stealing?
 
hey guys
 
anyone have any idea why the math doesnt add up in IE?
and it works for all other browsers
748 + 232 = 980
 
Xeo
Oh, hey @DeadMG!
Guess what, my Game of Life pixel shader is now able to use any By/Sx rules. :D
So, how long did you sleep?
 
ten hours
 
9:21 PM
@LucDanton What?
 
@Xeo So... how many hours do you sleep on average?
 
@FredOverflow It's like work stealing, without the work!
 
@JohnMerlino JavaScript or what?
 
it could be js but I think it is probably css issue, although js is involved. Take a look at this in chrome and then IE and you see a major difference: hllawgroup.com/home
in IE the main content area drops down
as if there isnt enough space for it within the container
but the size of the container should be able to accomodate both panel and main area
there is a js carousel scrolling within the main content area. but if you look at another page in IE, you will see that it doesnt drop down (since no js carousel) but still it seems to be a gap betwen panel and main content area. althugh in all other browsers it looks fine.
 
9:37 PM
@LucDanton Hm, the Boostcon videos have a low resolution, it's almost impossible to read the code on the slides :(
 
@FredOverflow for BoostCon 2010 some of the slides were available in a link in the description. I can't tell if it hasn't been done this year because e.g. the slides have not been passed to the uploader or if there are none available.
 
 
1 hour later…
10:40 PM
ok
I've forgotten how to write sfinae classes
what's wrong with this? seems like it should be fine to me
oh wait, it has to be sub-templated
ok, now it compiles, but it still doesn't work
that works fine on ideone, but MSVC won't accept it
 
yeah
now I have the reverse problem- MSVC won't reject it, even though the static assert failed
even if I place the static_assert in main(), then MSVC won't fail, even though Intellisense rightly comes up saying that it's been failed
 
Your puny static_assert cannot stop the power of the mighty compiler!
 
10:57 PM
@DeadMG I think test has to be a template, see this
 
yeah
I fixed that problem
ah
only one of them has to be templated?
 
11:24 PM
stop, hammer time!
 
@JohannesSchaublitb Ok, I stopped.
I just found out that you can get stack-like behavior from any container if you use it in a recursive function passing it by value.
This somehow helped me to implement a function for detecting cycles in a directed graph..
 
11:42 PM
@StackedCrooked: What?
 
11:56 PM
@JohannesSchaublitb In Soviet Russia (and elsewhere), time hammers you!
 

« first day (236 days earlier)      last day (4715 days later) »