in reply to Re: Re: Data copied with fork() -> how to access true data?
in thread Data copied with fork() -> how to access true data?
That's probably a good move anyway, though if there is any chance that you could upgrade your OS to something less than 10 years old, that would probably help your cause enormously also :)
With respect to rewriting your perl code, probably not.
For the most part, anything that runs on 5.6.1 should run on 5.8.x with minimal changes. That's a risky generalisation to make without having seen the code in question, but based on my own usage of both, it's not too wild a guess. Of course, my memory could be playing tricks on me again.
The harder question is how much effort will be required to make your current single threaded code run multi-threaded. On that, I will not even hazard a guess.
From the little information I have, your app is basically a big loop that get user input, uses it to modify the state of the current player, takes the opportunity to update the state of your NPC's and loops back for input.
Your desire is for the NPC's to run independantly of the user input. In theory, sharing the variables that contain their state with a background thread that loops over a sleep and modifies their behaviour is pretty trivial, but the devil is in the detail.
If your NPC's are OO-modelled, or if their state is maintained in nested hashes, or any number of other standard perl techniques, then the modifications could be awkward.
It may make more sense to simple use a timeout on your user input (using Term::ReadKey or similar), and just allow the NPC's to continue their state changes whilst the user thinks about his input.
How much effort would be involved, and whether multithreading would be beneficial relative to the other options available, will depend highly upon how your code is currently structured and how you want to modify it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Data copied with fork() -> how to access true data?
by muba (Priest) on Jun 01, 2004 at 19:50 UTC | |
by BrowserUk (Patriarch) on Jun 01, 2004 at 20:39 UTC | |
by muba (Priest) on Jun 01, 2004 at 21:17 UTC |