Re: [Dev-C++] 'extern const' and std::vector
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-05-04 15:42:05
|
I wouldn't recoment the use of a vector for the players - unless you expect the number of players to be constant for the lifetime of the program. It's better to use a list or similar. Your code will be simpler if you Select a container where the container iterator doesn't change when you insert/remove players (unless of course you remove the player that the iterator points to :-) Thread pools are used when you want quick response to new requests, while some operations are very slow. Either perform all operations through a thread pools, or just send out the expensive work. A thread pool is a number of threads blocking while they wait for a work unit to be delivered to them through a queue or similar. As soon as a thread gets something to do, it performs the action, taking its time. Then it releases the work object (player (?) maybe in this case) and starts listening on the work queue again. By using mutexes, semaphores or similar, the threads will not consume any time while waiting for work to do. The main program thread may pick up new player actions while the work threads performs all the grimy stuff. If it is important that all players gets the same number of 'actions' done and the main program gets back to a player that hasn't been released by the thread pool, the main thread might possibly block until the extra work is done. Normally, the thread pool should have had quite some time to perform the heavy stuff so for the majority of times, no blocking will occur. wxWindows has a lot of nice encapsulations for threads, database access, etc if you want to make the server - or the clients - portable to different oprating systems and platforms. /Per W On Sun, 4 May 2003, David McKen wrote: > > ----- Original Message ----- > From: "Ioannis Vranos" <iv...@at...> > To: <ci...@ya...> > Sent: Sunday, May 04, 2003 2:33 AM > Subject: RE: [Dev-C++] 'extern const' and std::vector > > > > > -----Original Message----- > > > From: David McKen [mailto:ci...@ya...] > > > Sent: Sunday, May 04, 2003 3:53 AM > > > To: Ioannis Vranos > > > Subject: Re: [Dev-C++] 'extern const' and std::vector > > > > > > > > > I must say thnk you to those who helped me. > > > > > > At firs ti have to note that you sent the email only to > me. I guess you > made > > this by mistake? :) > > > > Whoops my bad.. > > > > > > > > Istill have one question thoug about using a pool of > > > threads for a 'round > > > robin' approach. How would I implement such a system? > My > > > current idea is > > > that all the player objects will be in a vector and I > have > > > an int pointing > > > to the one that has been most recently processed. Once > a > > > thread is avalible > > > it reads this varible and moves on to the next object > in > > > the vector > > > (starting at the begining if it has reached the end), > > > updating the integer > > > so the next thread knows which object to process? Any > > > suggestions (or better > > > yet some example code) would be appreciated. > > > > > > > > I do not know thread magic (yet)... > > > > > > > BTW Ioannis we plan to make it multi-OS the library we > are > > > using is Opentop. > > > Unfortunately our goal to become truly os-independent > is > > > proving harder than > > > we thought. If push comes to shove we will stick with > the > > > *NIX and Win32 > > > (none of us on the developement team have a Mac to > > > playaround with). > > > > > > > > Why don't you use OpenGL, isn't it portable? > > > > This is the server we are talking about. Opentop does not > provide any > graphics classes. > The server is purely textbased. We hope to make a client > that will be > graphical (For that > we can use OpenGL).Opentop provides wrappers for various > things (threads, > sockets, etc). > > > > > My sugggestion is do not use Win32, use .NET instead. > > > > > > > > > > Ioannis Vranos > > > > * Programming pages: http://www.noicys.freeurl.com > > * Alternative URL 1: http://run.to/noicys > > * Alternative URL 2: http://www.noicys.cjb.net > > > > > > > __________________________________________________ > Do you Yahoo!? > The New Yahoo! Search - Faster. Easier. Bingo > http://search.yahoo.com > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |