code logs -> 2007 -> Sun, 03 Jun 2007< code.20070602.log - code.20070604.log >
--- Log opened Sun Jun 03 00:00:54 2007
00:07 Mahal is now known as MahalShop
00:30 TakyojiClone is now known as Takyoji
00:44 gnolam [lenin@Nightstar-13557.8.5.253.se.wasadata.net] has quit [Quit: Z?]
01:54 Yahir is now known as AnnoDomini
03:22 MahalShop is now known as Mahal
05:08 You're now known as TheWatcher
05:52 Vornicus is now known as Vornicus-Latens
05:58 ReivZzz is now known as Reiver
05:58 KBot [~karma.bot@Nightstar-29212.neoplus.adsl.tpnet.pl] has joined #Code
05:59 AnnoDomini [~farkoff@Nightstar-29692.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
05:59 KarmaBot [~karma.bot@Nightstar-29692.neoplus.adsl.tpnet.pl] has quit [Ping Timeout]
05:59 KBot is now known as KarmaBot
06:05 AnnoDomini [~farkoff@Nightstar-29212.neoplus.adsl.tpnet.pl] has joined #Code
06:05 mode/#code [+o AnnoDomini] by ChanServ
07:43 GeekSoldier|Sleep is now known as GeekSoldier
07:56 Takyoji [~Takyoji@Nightstar-25812.dhcp.roch.mn.charter.com] has quit [Quit: Leaving]
07:58 Forjadon [~Forjadon@Nightstar-1216.ue.woosh.co.nz] has joined #code
07:58 mode/#code [+o Forjadon] by ChanServ
09:34 Forjadon [~Forjadon@Nightstar-1216.ue.woosh.co.nz] has quit [Quit: Leaving]
09:41 ChalcyAFK [~Chalcedon@Nightstar-1216.ue.woosh.co.nz] has quit [Quit: Gone]
10:51 Mahal is now known as MahalSlep
12:35
<@jerith>
<mithrandi> "There are only 2 hard things in computer science: cache entry invalidation and naming things."
12:36
< Reiver>
12:47
< GeekSoldier>
hehe.
12:51
<@TheWatcher>
Pffft
12:51 * TheWatcher does disagree somewhat.
12:52
<@TheWatcher>
Only recently I had to fight off the urge to call something the "Open Multi-resource Group" file, with it's packed equivalent the "Zipped Open Multi-resource Group" file ¬¬
12:52
<@TheWatcher>
-'
12:56
< GeekSoldier>
bet that was hard.
12:58 gnolam [lenin@Nightstar-13557.8.5.253.se.wasadata.net] has joined #Code
12:59 mode/#code [+o gnolam] by ChanServ
13:00
<@jerith>
TheWatcher: http://omg.org/
13:02
<@TheWatcher>
Yes
13:02
<@TheWatcher>
I just love the "OMG TECHNICAL MEETING" on the fron page...
13:03
<@TheWatcher>
+t
13:17
<@AnnoDomini>
Hrm. How should I go about creating a Java application that has to have three threads and display the results of said threads' manipulations in an AWT/Swing GUI?
13:19
<@AnnoDomini>
Should I create the three threads, start them from main(), and somehow make it apply to the JFrame window?
13:22
<@AnnoDomini>
Or should the frame itself have a thread of its own, which would run simultaneously, somehow obtaining information from the three other threads?
13:23 * jerith has never done threads in Java.
13:24
<@AnnoDomini>
My main problem is communication between stuff.
13:24
<@TheWatcher>
AD: the latter - you should not attempt to allow several threads to directly access a swuig ui.
13:24
<@TheWatcher>
*swing
13:24
<@TheWatcher>
Also, in advance, I suggest that you lose your hair and sanity, because you /will/ have lost them by the time you're done.
13:25
<@AnnoDomini>
How does one obtain info in a situation like this?
13:25 * AnnoDomini has not sanity. Hair might be a problem.
13:25
<@TheWatcher>
by normal thread communication methods
13:26 * AnnoDomini is pretty damn ignorant here.
13:26
<@AnnoDomini>
Should I... I dunno, create methods in the thread classes that would be able to grab what the threads changed?
13:27
<@jerith>
Perhaps add methods to your GUI thread that allow the worker threads to send notifications.
13:27
<@TheWatcher>
I suggest you search google for something like "java thread communication", and expect to spend a lot of time reading before you implement anything
13:27
<@jerith>
Unless Java already has a notification API, which I suspect is the case.
13:28
<@TheWatcher>
jerith: there are several ways to do it
13:28
<@jerith>
None of them anything approaching sane, I take it?
13:28
<@AnnoDomini>
Sadly, time is something I do not have.
13:29 * AnnoDomini just knows he'll fail this semester utterly and be forced to reattend second year.
13:30
<@gnolam>
Look on the bright side - you'll get to avoid growing up for another year. :)
13:30
<@AnnoDomini>
!
13:30
<@AnnoDomini>
You have a point there.
13:31
< Reiver>
...?
13:31
<@gnolam>
University is like Neverland with booze.
13:32
<@AnnoDomini>
I knew I should have gone to the Humanities division, to something like English Philology. I'd just have to occassionally get off my ass to get signatures of "you pass" and that'd be the extent of my required work.
13:32
<@gnolam>
Amen.
13:33
< Reiver>
?
13:34
<@AnnoDomini>
gnolam: Say, want to house four rowdy foreigners for a few days in the summer?
13:34
<@gnolam>
Err...
13:34
<@gnolam>
Wha?
13:34
< Reiver>
(It's okay. They promise only to steal a maximum of three items of clothing from you.)
13:34
<@AnnoDomini>
Myself, EvilDarkLord, ErikMesoy and Attilla are going for a Tour de Europe.
13:35
<@gnolam>
Oh?
13:35
<@AnnoDomini>
Yup. Two month's worth of driving around and taking photos to brag about upon returning.
13:35
<@AnnoDomini>
Possibly gaming via HotSpots.
13:36
< Reiver>
And they're looking for vict^H^H^Holinteers to put them up for a few nights here and there.
13:36
<@gnolam>
Sounds like fun. :)
13:37
< GeekSoldier>
from what country are you, gnolam?
13:37
<@jerith>
The Frozen North.
13:37
<@jerith>
Vikingia.
13:37
<@jerith>
(Sweden.)
13:37
<@AnnoDomini>
People's Republic of Sweden.
13:37
< GeekSoldier>
heh, wish I had enough leave to join you!
13:38
<@AnnoDomini>
AFAIK, additional participants are welcome. Provided they supply their own vehicular transportation.
13:39
<@gnolam>
And that is where it all breaks down for me. :(
13:39
<@gnolam>
Oh well. Maybe next year.
13:39
<@gnolam>
As for housing people... you do realize my apartment is a whopping 25 m^2, right? ;)
13:40
<@AnnoDomini>
It's certainly bigger than the tent EDL's thinking of bringing.
13:44
<@gnolam>
Tents usually don't have furniture inside them. :)
13:45
<@AnnoDomini>
But occassionally have bears.
13:45
<@gnolam>
So does my apartment.
13:45
<@AnnoDomini>
<_<
13:45
<@gnolam>
(It is what my middle name means)
13:46
<@AnnoDomini>
Bjorn?
13:47
<@gnolam>
10 points to the Polish contestant!
13:47
< Reiver>
You guys are planning to rough it for two months in tents in europe?
13:47
<@AnnoDomini>
Pretty much.
13:47
< GeekSoldier>
certainly sound like fun. depending on where I'm at at the time, I'll see if I could put you up somewhere.
13:48
<@AnnoDomini>
We aren't taking anyone with poor health.
13:48
<@gnolam>
Do tell me if you're planning on doing it again next year (or the one after that). I think I'll have both time and transport then.
13:48
< Reiver>
So you're avoiding cities, then?
13:48
< Reiver>
Or planning to set up tents in car parks?
13:48
< GeekSoldier>
that is, if you're coming through southern Germany.
13:48
<@AnnoDomini>
Nah. We'll visit cities, but paying to get housed in hotels/motels would be a tad too costly to do every day.
13:49
<@AnnoDomini>
I'm certain there are tent fields in Europe.
13:49
< Reiver>
Have you looked up where yet?
13:49
< Reiver>
Also: Look up backpackers. They sound about your alley.
13:49
<@gnolam>
I've heard Slovakian hostels are great.
13:49
< Reiver>
(AKA minimum price for a roof and a bed.)
13:49
<@AnnoDomini>
Nope. I'm currently looking through european regulations.
13:50 * gnolam scores 5 reference points and is now in the lead!
13:50
<@AnnoDomini>
The speeding fines are exorbitant.
13:50
<@gnolam>
They usually are.
13:50
<@AnnoDomini>
They're very tame in Poland.
13:50
< Reiver>
"Well you shouldn't have been speeding, should you now?"
13:51 You're now known as TheWatcher[afk]
13:51
<@AnnoDomini>
But I like speeding - that is, going as fast as I think I should be able to pull off safely.
13:51 * jerith just paid R100 for his sister doing 93 in an 80 zone.
13:51
< Reiver>
jerith: So you, uh, don't have speeding fines then? ;)
13:51
< Reiver>
(R100 is what, five bucks?)
13:51
<@gnolam>
The NZ ones are pretty hefty, IIRC.
13:51
<@jerith>
(In my car. She'll pay it back. Eventually.)
13:51 * Reiver coughs.
13:52
< Reiver>
NZ ones are, IIRC, $10/km over the limit.
13:52
<@jerith>
About US$15ish.
13:52
<@gnolam>
And the cops are very persistent. I don't know /how/ they managed to trace my brother all the way back here for a measly speeding ticket.
13:52
< Reiver>
Leeway of +10% before you stop being able to protest the limit.
13:52
<@jerith>
That was particualrly cheap, though.
13:52
<@AnnoDomini>
I was doing 75 in a 50 zone, and only got 100 PLN.
13:52
< Reiver>
Oh, and
13:52
<@jerith>
Usually it's about three times that.
13:53
< Reiver>
jerith: So she blew the officer?
13:53
<@gnolam>
So... your sister is hot then. ;)
13:53
< Reiver>
;)
13:53 * jerith thwaps Reiver.
13:53
< Reiver>
If you do more than 40 over the limit in any zone you get automatically charged with dangerous driving and you lose your liscence.
13:53
<@jerith>
I'll thank you to not put that kind of picture in my head regarding my sister.
13:53
< Reiver>
... As well as the NZ$400+ fine.
13:53
<@jerith>
This was an automated camera fine, though.
13:54
<@AnnoDomini>
Over here, 500 PLN is max what you can get.
13:54
< Reiver>
jerith: Oh come now. It's not nearly as bad as picturing her doing so through the drivers window, to a middleaged mustached police officer with his fly unzipped...
13:54 * Reiver flees
13:54
< GeekSoldier>
so that's what the new stain on the door lining was.
13:55
<@AnnoDomini>
IIRC, going over the limit by 50 or more you can do twice with an otherwise clean record before they take away your license.
13:55
< Reiver>
Watch out for the one on the seat... she enjoyed doing it.
13:55
< Reiver>
¬¬
13:55
< Reiver>
Anno: To be fair, one of NZ's main road killers was for many years, speeding.
13:55
< GeekSoldier>
damn, I think we just sent jerith into convulsions.
13:56
<@jerith>
Nah, just trying to figure out why VNC doesn't like me.
13:56
<@AnnoDomini>
Though drunk driving over here is almost automatically a jail sentence.
13:56
< Reiver>
Ours isn't quite that bad.
13:56
< Reiver>
But drunk driving is a 'serious' offense.
13:56
<@gnolam>
30 over the limit here and you lose your license on the spot. Otherwise, it's three strikes (one strike is deducted every... something years).
13:56
< Reiver>
Speeding is a misdemeanour, drunk driving gets you in The Deep Shit.
13:57
< Reiver>
gnolam: Ah, we have demerit points. You're not allowed over 100, and someone in their infinite sense of humor decided getting caught speeding would be worth 34 demerit points...
13:57
<@AnnoDomini>
We have a point system. You get some amount (I forget, probably 24) per year. For slowest speeding, you get 4 points. For the fastest, 12.
13:57
< Reiver>
Anno: Sounds like they don't much mind people speeding, then?
13:57 * jerith has Opinions about drunk driving.
13:58
<@AnnoDomini>
Not really.
13:58 * Reiver ponders.
13:58
<@AnnoDomini>
Recently, they outlawed the cops hiding with radars.
13:58
< Reiver>
Anno: What're your roads like?
13:58
<@AnnoDomini>
Now, they have to do that in clearly visible places.
13:58
<@AnnoDomini>
Reiver: Terrible.
13:58
<@jerith>
There's a difference between "I have alcohol in my system" and "my driving is impaired".
13:58
< Reiver>
...huh.
13:59
< Reiver>
jerith: Certainly. In NZ you have to be over a certain limit before they can book you for drunk driving.
13:59
<@jerith>
The problem is that the latter differs from person to person.
13:59
<@jerith>
Sure.
13:59
<@jerith>
Here too.
13:59
< Reiver>
Less... than you'd think.
13:59
<@jerith>
Except that limit here is about two beers.
13:59
< Reiver>
On a %blood alchohol level.
13:59
<@AnnoDomini>
Our former limit was about 1 beer.
14:00
< GeekSoldier>
in Germany, the level is so low that they could pull you in after one beer.
14:00
< Reiver>
The main issue with the 'low level' drink-driving is that it impairs your reflexes.
14:00
< Reiver>
Not that you're completely pissed.
14:00
<@jerith>
I am perfectly capable of driving (and being entirely rational in plenty of other areas too) after three or so.
14:00
< Reiver>
Rational is no issue.
14:00
<@jerith>
Reiver: No more than being a bit tired.
14:00
< Reiver>
Reactions is another entirely that is much, much harder for your average person to measure.
14:01
<@jerith>
Sure.
14:01
<@jerith>
But then enforce that across the board.
14:01
<@jerith>
Pull people over if they haven't slept in 20 hours.
14:01
< Reiver>
In NZ, they're planning to.
14:01
<@jerith>
You're just as dangerous drowsy as you are smashed.
14:01
< Reiver>
I am a bit scared of this, as it is going to cause Personal Strife for such issues.
14:02
< Reiver>
(They're testing a new sort of breath-tester, that will pick up pot, ampetamines, speed, alchohol, and even excessive tiredness.)
14:02
<@jerith>
Then again, this is all very nanny-statist.
14:02
<@gnolam>
Gonads & Strife?
14:02
<@gnolam>
... breath-testing tiredness?
14:02
< Reiver>
gnolam: Sure. Tiredness is partly a toxin buildup in your body.
14:02
< Reiver>
They can detect it on your breath.
14:03
< Reiver>
(My issue with the system is that I take medication that will register as a false-positive.)
14:03
<@jerith>
It's all very well saying "Something Must Be Done" when someone with half a bottle of vodka in his system kills a child with a car.
14:04
<@jerith>
But stopping me having a beer or two with friends after work is *way* beyond reasonable.
14:04
< Reiver>
jerith: Here, the main killer is increasingly the 'slightly tipsy' ones.
14:04
< Reiver>
The propaganda campaigns have helped dramatically cut down on the Totally Smashed folks.
14:04
<@jerith>
How do drunk drivers compare to other road accidents statistically?
14:04
< Reiver>
... And yet they've found that there's a perception for 'Oh, I'll be fine' in the Mildly Tipsy cases.
14:05
< Reiver>
jerith: I think they're our #3 or something killer.
14:05
<@jerith>
And how are these statistics compiled?
14:05
< Reiver>
Speeding and Booze are Right Up There.
14:05
< Reiver>
Uh
14:05
< Reiver>
Police accident reports
14:06
< Reiver>
If you're in in a car crash they can test you for alchohol levels etc.
14:06
< Reiver>
NZ, I note, had a chronic speed/drinking problem, though.
14:07
< Reiver>
So the two are the Big Things the traffic cops have been trying to crack down on.
14:07
<@gnolam>
#4 is "collision with kiwi".
14:07
< Reiver>
(I still find their $Stings hilarious in results.)
14:07
<@gnolam>
#5: Entangled in Peter Jackson's beard.
14:08
< Reiver>
(To whit: At 1AM on a party night, they put a roadblock on every single exit from the main city center.)
14:08
<@gnolam>
#6: Attempting to drive to Australia.
14:09
<@jerith>
http://www.dammdrinker.com/ <-- Not the site I was looking for, but close enough.
14:09
< Reiver>
(The number of arrests they make is rivaled only by the number of Hilarious Anecdotes of cars pulling sudden U-turns, seen by another roadblock doing the same thing, and then parking on the grass and the occupants seen getting out of the car and legging it... ...apparently forgetting the police can just trace the liscence plates.)
14:09
< Reiver>
Recently though, they got -nasty-
14:10
<@gnolam>
Reiver: ah, but can they prove that the people inside were drunk?
14:10
< Reiver>
gnolam: No, but they can still ping them for breaking parking and traffic laws.
14:10
< Reiver>
And then have the car towed ¬¬
14:10
<@gnolam>
Which is usually preferrable to getting busted for drunk driving.
14:11
< Reiver>
See, NZ has had a bit of a problem with 'boy racers' and other subsets who get caught, protest they can't afford to pay the fines, and then carry on anyway.
14:12
< Reiver>
So recently, the police started setting up the roadblocks with Ministry Of Justice baliffs on hand.
14:12
< Reiver>
Every car going through not only got checked for drink driving, but the baliffs ran a quick check for outstanding fines... and then confiscated the vehicles.
14:14
< Reiver>
The most hilarious results were the case of people who then attempted to come to blows over the matter /amongst police officers and court baliffs/ -- and an interesting number of Irate Parents, whom a surprising proportion thereof were wondering if they couldn't perhaps swap the car for jail time for the little $#@!s that got the family car impounded for fines the parents didn't know existed...
14:16
<@gnolam>
Heh.
14:52
<@AnnoDomini>
YAY MY THREAD WORKS!
14:53 * jerith pulls on the loose end.
14:53 * EvilDarkLord also learned about threads a day ago in Python :)
14:53
<@jerith>
"Lisp is a lousy language for doing any particular problem. What it's good for is finding the right language for the problem and embedding that in lisp.)
14:53
<@jerith>
s/)/"/
14:54
< GeekSoldier>
see, you were thinking lisp, and started using parens automatically.
14:58
<@jerith>
Probably.
14:59
<@jerith>
Was quoting Ableson.
15:06 Vornicus-Latens is now known as Vornicus
15:14 * ToxicFrog resyncs
15:14
<@ToxicFrog>
AD has to do thread assignments in Java? ghhhkkkkk
15:14 * jerith needs a proper mouse for this.
15:15
<@AnnoDomini>
ToxicFrog: Yes. We do.
15:15
<@jerith>
Actually, I need a tablet. But a mouse is better than a touchpad.
15:15 * ToxicFrog patpats
15:16
<@AnnoDomini>
I'm pretty sure I'll fail Theory and Project, but at least I'm reasonably sure I'll pass Practice. :D
15:16
<@ToxicFrog>
(I learned threads in CacheOS, then pthreads, then ported the semantics of the former to Lua using the latter)
15:22 You're now known as TheWatcher
15:35
<@TheWatcher>
AD: what level java are you supposed to be doing?
15:35
<@AnnoDomini>
I'm not certain what you mean.
15:35
<@TheWatcher>
Because in our java courses, threads aren't even mentioned until the advanced course
15:36
<@AnnoDomini>
This is our first semester with Java.
15:36
<@ToxicFrog>
Here, threads are covered first semester of second year - but they're covered in C, which at that point you've already been using for at least a year.
15:36
<@TheWatcher>
(and even then they are introduced as "Java threads: don't use them. We mean it. Really. Unless you /seriously/ know what you're doing, that way lies madness and spiders")
15:36
<@AnnoDomini>
We didn't have threads in C++ last semester.
15:37
<@AnnoDomini>
We've got assigned a total ass of a Practice teacher, who didn't teach us a damn thing.
15:38
<@AnnoDomini>
We either had to search and learn on our own, or fail.
15:38
<@AnnoDomini>
While that bastard just sat at his terminal and browsed forums.
15:39
<@AnnoDomini>
Hm... How do you change a color after creation?
15:39
<@AnnoDomini>
colorName(r,g,b)?
15:47
<@AnnoDomini>
So, how do I send a value over from one thread to another?
15:49
<@AnnoDomini>
Should I perhaps use some sort of global variable?
15:53
<@AnnoDomini>
I have a major problem with understanding how to work with local variables in OOP. I can't seem to refer to object instances (created in main()) from within the run() method of a class.
15:54
<@ToxicFrog>
Java does not have function closures, if that's what you're trying.
15:54
<@AnnoDomini>
Function closures?
15:54
<@AnnoDomini>
What's that?
15:55
<@ToxicFrog>
Functions that can refer to variables that are in scope when they are declared, even if those variables are no longer in scope when they are called.
15:55
<@ToxicFrog>
for example:
15:55
<@ToxicFrog>
do
15:55
<@ToxicFrog>
local foo = 1
15:55
<@AnnoDomini>
I just want to grab the value of a variable of a thread object from within another thread object.
15:55
<@ToxicFrog>
function bar() print(foo) end
15:55
<@ToxicFrog>
end
15:56
<@ToxicFrog>
bar() -> displays "1" even though foo is no longer in scope
15:57
<@ToxicFrog>
...er?
15:57
<@AnnoDomini>
I have four threads. Three of those threads run loops which cyclically change a value.
15:57
<@AnnoDomini>
The fourth is meant to visualize the three values as a color.
15:58
<@ToxicFrog>
Ok. And you're having trouble coming up with an ITC mechanism.
15:58
<@AnnoDomini>
"ITC mechanism"?
15:58
<@ToxicFrog>
InterThread Communication.
15:58
<@ToxicFrog>
Like IPC, except across threads.
15:58
<@AnnoDomini>
Oh.
15:59
<@AnnoDomini>
Yes. That's exactly what I've trouble with.
15:59
<@ToxicFrog>
The traditional way is to have some kind of lockable global (or file static) that they use, at least in pthreads, but I have no idea how Java handles such things.
15:59
<@AnnoDomini>
Neither do I. ;)
16:00
< Reiver>
Java has a state you can add onto an initialisable variable.
16:00
< Reiver>
That then sets up the lockable gizmo.
16:01
< Reiver>
Also, while i = i + 1; is able to be interrupted midthread, ++i; is not. Or was it i++; one of those two.
16:01
< Reiver>
(Just a minor Curiosity that was noted.)
16:05
<@TheWatcher>
you need synchronised methods in your ui control object which the other threads call to set the values that should be displayed
16:10 * AnnoDomini tries to understand, fails.
16:10
<@AnnoDomini>
What does synchronized mean in this context?
16:12
<@Vornicus>
synchronized methods lock the object they are called on.
16:12
<@AnnoDomini>
What does 'locking an object' mean?
16:13
<@Vornicus>
It means that no other threads can talk to it until the method is done.
16:14
<@TheWatcher>
... AD, read: http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html
16:15
<@TheWatcher>
]seriously
16:15
<@TheWatcher>
because unless you understand at least that inside out, you're nbot going to get this working
16:18
<@AnnoDomini>
I'll try. Thanks.
16:24
<@AnnoDomini>
Haha! Using 'global' variables worked.
16:26
<@Vornicus>
eeew
16:28
<@AnnoDomini>
Now that it works, I need to figure out how to make the actual interface, where one can set the frequency of RGB changes, set the RGB values to move sliders, and set up a 3D graph that presents the color.
16:31
< Reiver>
...One note Anno
16:31
< Reiver>
Global variables in multithreads can do very bad things
16:31
<@AnnoDomini>
They can?
16:32
<@ToxicFrog>
Reiver: that's what synchronized is for, yes?
16:32
<@Vornicus>
Synchronized is for methods.
16:32
< Reiver>
TF: Correct, but I have a sudden abject fear that Anno has not bothered with the synchronized bit.
16:33
<@AnnoDomini>
I barely understand what that is and what it means. Not at all how to implement it.
16:33
<@ToxicFrog>
...aah.
16:34
<@ToxicFrog>
Well, what Reiv is getting at is that you need some way of preventing multiple threads from trying to access the variable simultaneously.
16:34
<@Vornicus>
Usually you do this by encapsulating your variables in an object and using methods that have the "synchronized" keyword to access them.
16:34
<@AnnoDomini>
They won't.
16:34
< Reiver>
Because the problem with 'simultaneously' is that multithreading is not, uh, coherant.
16:34
< Reiver>
Your functions do not take turns.
16:35
< Reiver>
Your functions can, in fact, be interrupted halfway through the code.
16:35
< Reiver>
And then /another/ function can pop in and start manipulating the same variable.
16:35
<@ToxicFrog>
Well, depends on the threading model. But in Java (and pthreads), yes.
16:35
<@ToxicFrog>
The classic example of this is:
16:36
< Reiver>
TF: I was referring to Java, yes
16:36
<@ToxicFrog>
Threads A and B want to increment a variable, which is currently 1.
16:36
<@ToxicFrog>
(1) A reads the variable, gets 1.
16:36
<@ToxicFrog>
(2) B interrupts A, reads the variable, gets 1, adds 1 to get 2, saves 2.
16:36
<@ToxicFrog>
(3) A resumes, adds 1 to the 1 it read earlier to get 2, saves 2.
16:36
<@ToxicFrog>
(4) The variable is now 2 instead of 3.
16:37
<@AnnoDomini>
They can't really access the same variable at the same time. That's because each has its own variable. And the only thread that accesses all the variables only reads them.
16:37 MyCatVerbs [~mycatverb@Nightstar-13709.lurkingfox.co.uk] has joined #code
16:41
< Reiver>
The one that reads them all is able to read them before he previous ones have finished, and /not know any better/ then.
16:41 Reiver is now known as ReivZzz
16:42
<@AnnoDomini>
Doesn't matter if it skips a beat. Or ten.
16:44
< ReivZzz>
Anno: ...right.
16:44
< ReivZzz>
You realise it would read it once /regardless of the state of completion/, think it's finished, and move on, yes?
16:44
<@AnnoDomini>
Yes. Of course.
16:45
< MyCatVerbs>
/?
16:45
<@Vornicus>
I think Anno's thing is "since we're reading it over and over, race conditions don't matter, because we don't need perfect exactness anyway"
16:45
<@AnnoDomini>
Yes.
16:45
< MyCatVerbs>
Qu'est-ce que la sujet, s'il vous plait?
16:46
<@Vornicus>
Threading, a color spinner, and race conditions.
16:46
< MyCatVerbs>
Sounds hysterical. Debaucherous, even.
16:48
<@AnnoDomini>
I wonder how this thing will work on 'awesome' Uni machines, if it's slow on my box.
17:00
<@ToxicFrog>
This is in fact OWMR, so you should be able to safely omit locking given that the state of the variable is always consistent.
17:01
<@AnnoDomini>
OWMR?
17:03
<@ToxicFrog>
One Writer, Many Readers.
17:05
<@AnnoDomini>
Sort've, yeah.
17:11 You're now known as TheWatcher[afk]
17:35 Derakon[AFK] is now known as Derakon
17:48
<@AnnoDomini>
Gawd, Java is a memory and CPU hog.
17:50
< GeekSoldier>
You just now figure this out, AD?
17:50
<@AnnoDomini>
No. But it's pronounced especially now.
17:51
< GeekSoldier>
I could imagine.
18:22 * Derakon fixes more collision bugs! What fun!
18:22
< GeekSoldier>
huzzah.
18:23
<@Derakon>
Handling collision with multiple terrain tiles in a single frame is kinda pricy, lemme tell you.
18:23
<@Derakon>
First: recognize each collision, store the results.
18:23
<@Derakon>
Second: try each backout vector in turn, seeing if any single one of them is enough to avoid collision with all of them.
18:23
<@Derakon>
Third: if not, then perform the first backout vector, then recollide with every single other tile to get new backout vectors to use.
18:25
< GeekSoldier>
sounds bad. there's no way to do it with less processing?
18:25
<@Derakon>
Everything else I've tried has resulted in undesirable behaviour.
18:25 * GeekSoldier nods.
18:25
<@Derakon>
For example, this situation: http://66.235.60.44/~chriswei/temp/polygon4.png
18:26
<@Derakon>
In this case, C is moving up and to the right into A and B.
18:26
<@Derakon>
The ideal behaviour is that C simply scrapes along the ceiling.
18:26
<@Derakon>
The reality was that I was reacting to each collision as it occurred, which meant that first B pushed me to the left, killing my horizontal velocity, and then A pushed me down, killing my vertical velocity.
18:32
< GeekSoldier>
but you're getting to a more appropriate behavior?
18:32
<@Derakon>
The logic I outlined earlier in the three steps is what I'm using to dodge that.
18:33
<@Derakon>
Basically, I say "Okay, I've collided with A and B this frame. Can B's backout vector get me out of colliding with A? No. Can A's backout vector get me out of colliding with B? Yes. Okay, I'm done."
18:35 You're now known as TheWatcher
18:42 GeekSoldier_ [~Rob@Nightstar-5549.pools.arcor-ip.net] has joined #code
18:43 GeekSoldier [~Rob@Nightstar-3682.pools.arcor-ip.net] has quit [Ping Timeout]
18:43 GeekSoldier_ is now known as GeekSoldier
18:52 Ev3 [~Z@87.72.36.ns-26407] has quit [Quit: User has been exiled from stupid-land.]
19:48
<@AnnoDomini>
"Finished, completed, best play in the woooorld!"
19:49
<@AnnoDomini>
http://pastie.caboo.se/67450 :D
19:50
<@Derakon>
Hmm...put the red/green/blue stuff into arrays with RED, GREEN, BLUE as constant indices. ;)
19:50 AnnoDomini [~farkoff@Nightstar-29212.neoplus.adsl.tpnet.pl] has quit [Quit: Patience is a virtue.]
19:50
<@Derakon>
Or not.
19:59 AnnoDomini [~farkoff@Nightstar-29212.neoplus.adsl.tpnet.pl] has joined #Code
19:59 mode/#code [+o AnnoDomini] by ChanServ
20:00
<@AnnoDomini>
Pfew. After Java ate my resources, I had to reboot.
20:02
<@AnnoDomini>
Derakon: Uh, what? I don't think I've used a constant color in there, besides the pen/background colors.
20:05
<@Derakon>
No, I meant that you have separate variables for red, green, and blue. It's a lot of namespace pollution. Personally I'd create an array for each of the different things where you have three variants of the same thing, and then use RED, GREEN, and BLUE as stand-ins for 0, 1, and 2.
20:06
<@Derakon>
Possibly, possibly.
20:06
<@Derakon>
Er, wrong channel.
20:08
<@AnnoDomini>
That idea has merit... but I believe it would be more work than it's worth.
20:08 * Derakon shrugs.
20:28 GeekSoldier is now known as GeekSoldier|Sleep
21:27 * Derakon streamlines his map editor code a bit to take advantage of right- and middle-clicks.
21:27
<@Derakon>
Left = cycle through terrain orientations. Right = cycle in other direction. Middle = delete tile.
21:36 * gnolam has a business idea.
21:36 * gnolam writes it down for future reference.
21:38 * EvilDarkLord wonders if mentioning it here means gnolam wants people to ask about it.
21:39 AnnoDomini [~farkoff@Nightstar-29212.neoplus.adsl.tpnet.pl] has quit [Connection reset by peer]
21:43 AnnoDomini [~farkoff@Nightstar-29212.neoplus.adsl.tpnet.pl] has joined #Code
21:43 mode/#code [+o AnnoDomini] by ChanServ
21:43 * EvilDarkLord eyes the memory manager (Ubuntu). Any idea why it would start eating swap when there is a good 700 MB of RAM left?
21:44
<@Derakon>
Swap should always be fully in use. *shrug*
21:45
<@jerith>
How much of that ram is full of buffers and cache?
21:46 AnnoDomini [~farkoff@Nightstar-29212.neoplus.adsl.tpnet.pl] has quit [Quit: Some people find sanity a little confining.]
21:46
<@jerith>
It makes sense to use ram to cache stuff that's being used rather than holding onto data that nothing cares about right now.
21:47
<@ToxicFrog>
...er, no.
21:47
<@ToxicFrog>
Swap use should be minimized.
21:48
<@jerith>
Well.
21:48 * EvilDarkLord er, doesn't have the answer to jerith's question due to too much newbieness.
21:48
<@jerith>
It's complicated.
21:48
<@ToxicFrog>
EvilDarkLord: 'top'
21:48 AnnoDomini [~farkoff@Nightstar-29212.neoplus.adsl.tpnet.pl] has joined #Code
21:48 mode/#code [+o AnnoDomini] by ChanServ
21:48
<@jerith>
[jerith@jerith-lap0 ~]$ free total used free shared buffers cached
21:48
<@jerith>
Mem: 1551936 992712 559224 0 75344 397048
21:48
<@jerith>
-/+ buffers/cache: 520320 1031616
21:48
<@jerith>
Swap: 1048568 452 1048116
21:48
<@ToxicFrog>
Mem: 508728k total, 502748k used, 5980k free, 5048k buffers
21:48
<@ToxicFrog>
Swap: 1052248k total, 155492k used, 896756k free, 66260k cached
21:49
<@ToxicFrog>
-- from top
21:49
<@jerith>
Ack! irssi broke my formatting.
21:49
<@ToxicFrog>
It tends to do that.
21:49 * AnnoDomini is still happy at completing that damn homework program. :)
21:49
< EvilDarkLord>
Mem: 1035648k total, 606332k used, 429316k free, 95312k buffers
21:49
< EvilDarkLord>
Swap: 682688k total, 33800k used, 648888k free, 212172k cached
21:51
<@jerith>
I'm guessing stuff was paged out at some point to make room for data or cache.
21:51
<@ToxicFrog>
And hasn't been needed since, so it hasn't been paged back in.
21:52
<@jerith>
The memory that was allocated has since been freed, so you have spare RAM.
21:52
<@jerith>
Of your 430m free, though half of it is still caching something.
21:52
< EvilDarkLord>
Ah, I see. Cheers.
21:53 MahalSlep is now known as Mahal
22:05 Derakon is now known as Derakon[AFK]
22:05 Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has joined #Code
22:13 Vornicus is now known as IanMusgrave
22:57 You're now known as TheWatcher[T-2]
23:01 You're now known as TheWatcher[zZzZ]
23:35 Chalcedon [~Chalcedon@Nightstar-1216.ue.woosh.co.nz] has joined #code
23:35 mode/#code [+o Chalcedon] by ChanServ
23:51 gnolam [lenin@Nightstar-13557.8.5.253.se.wasadata.net] has quit [Quit: Dynamics.]
--- Log closed Mon Jun 04 00:00:59 2007
code logs -> 2007 -> Sun, 03 Jun 2007< code.20070602.log - code.20070604.log >