Hi,
in my application I need to construct a large data structure
at startup. This data structure is needed (read-only) by all
sessions. I tried this approach:
| // my webapp's backend class
| class MyBackend {
| [...]
| private:
| static LargeScoreTable *scoreTable;
| };
|
| // my webapp's backend's implementation
|
| // static var's instance
| LargeScoreTable MyBackend::scoreTable = NULL;
|
| // constructor
| MyBackend::MyBackend ()
| {
| if (scoreTable == NULL)
| {
| std::cout << "creating score table..." << std::endl;
| scoreTable = doTimeIntensiveStuff();
| }
| }
|
| // my webapp's constructor
| MyWebApp::MyWebApp ()
| {
| this->backend = new MyBackend ();
| }
Now this does not seem to work - the first session works just
fine, but as soon as I open a concurrent session, the data in
the scoreTable field seems corrupted.
Is this "normal" behaviour? How would you normally propose to
implement this kind of stuff? The Backend performs some
calculation on data uploaded by the user, it thus carries a
state which is specific to the webapp's session. The scoreTable
however needs to be loaded only once and should ideally be
shared by all sessions.
Cheers,
Martin
--
----------- / http://herbert.the-little-red-haired-girl.org / -------------
=+=
One good reason why computers can do more work than people is that they
never have to stop and answer the phone.
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest