On Tue, 30 Jul 2002, Steve Keith - Baselines wrote: > Thanks Carl - this will help me out, and I think it will be fairly easy to > implement. > > I usually queue within the program all database updates in memory, then > commit them taking the smallest possible slice of time. > > Let me ask you if this sounds reasonable: > > Instead of doing the commit mentioned above, (i.e. $DB{$key}=$r_data;) in > the body of the program, I would fork off a process and pass it the database > name, the key, and the reference to the data to store under the key. As > long as the fork command gets executed, the database is updated by the new > process. If the fork command does not complete, then the database stays the > way it was. Is this how it works? All the variables available to the main > program will be available to the forked process, correct? >
As far as I know, the fork process works by making a copy of all variables (excpet file handles) from the forker process to the forkee process (to coin a few nasty sounding terms). However, I'm not certain how perl references work in a forked environment. If the reference count is not increased when the copy of the reference variable is made, I'm not sure what happens when the reference variable in the forker goes out of scope. If the reference count is increased when the copy is made, there should be no problem but if it doesn't and the reference count goes to zero when the forker process does its stack cleanup and global garbabe collection, I don't know what happens to the reference but I'm pretty sure it wouldn't be pretty. Just to be safe, I would avoid use of references and simply rely on global variables as a way to pass data/information between the forker and the forkee. Perhaps someone a lot more conversant with perl internals and the details of whether perl does anything special with references when forking can offer better advice. **** [EMAIL PROTECTED] <Carl Jolley> **** All opinions are my own and not necessarily those of my employer **** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs