Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
WorldStatePool Class Reference#include <WorldStatePool.h>
Inheritance diagram for WorldStatePool:
![]() Detailed Descriptionholds multiple instances of WorldState, allows one process to be updating while another is readingUse the AutoGetReadState and AutoGetWriteState to access individual WorldState entries... their constructors and destructors allow WorldStatePool to keep track of which entries are in use. When a state wants to write, it is given the oldest unused entry to write into. During writing, other accessors can read the newest (complete) entry, or concurrently write into a different entry (in case they don't want to wait for the other process to finish). A global lock (lock) is used while choosing an entry, and individual locks (writeLocks) are used while writing into entries (to easily allow readers to block on the lock until writing is done) One point of trickiness is that entries being written are moved to the end of the list when the writing begins, not when it is complete. Readers can always scan backwards in the list to find the newest entries, but writers must check the end to see if newer (or equivalent) frames are already in progress, as well as the beginning to find the oldest unreferenced. When a writer tries to access an entry, and another writer is already processing that frame, if blocking is set then the writer will given that entry once the original is done with it (so check your frame index when you receive it so you can tell if it was already processed). If blocking is *not* set, then you will get a separate entry with no indication another process is also working on the same frame. Definition at line 42 of file WorldStatePool.h.
Member Typedef Documentation
Member Enumeration Documentationflags for the status field on each WriteRequest -- tracks partial completion when multiple writers are involved
Definition at line 135 of file WorldStatePool.h.
Constructor & Destructor Documentation
this shouldn't be called...
Member Function Documentation
returns true if the process should call read (i.e. msg has new or unprocessed data (such as motion needs to supply feedback)) only one call to this can be made at a time per process (not threadsafe, but is multi-process safe)
Definition at line 119 of file WorldStatePool.cc.
takes a sensor update from the simulator/system, updates an entry in the pool with the new information If isUnread() returns non-NULL, you should acquire a WriteRequest, and check that it succeeds, is current, and is still incomplete, before calling read()
Definition at line 154 of file WorldStatePool.cc.
processes a request, passed as either a ReadRequest or WriteRequest, to access an entry in the pool
Implements Resource. Definition at line 183 of file WorldStatePool.h. Referenced by doUseResource().
completes access to an entry in the pool, you must pass the same request instance here which you originally passed to useResource()
Implements Resource. Definition at line 185 of file WorldStatePool.h. Referenced by doReleaseResource().
does the actual work of useResource() this is split off as a non-virtual function to avoid some process identity issues that occur with virtual functions under Aperios Definition at line 34 of file WorldStatePool.cc.
does the actual work of releaseResource() this is split off as a non-virtual function to avoid some process identity issues that occur with virtual functions under Aperios Definition at line 60 of file WorldStatePool.cc.
shorthand to test if all three P, I, and D values are 0 for the specified joint index (relative to 0, not PIDJointOffset)
Definition at line 211 of file WorldStatePool.h. Referenced by read().
called when access to an entry for reading is requested
Definition at line 287 of file WorldStatePool.cc. Referenced by doUseResource().
called when an read access to an entry is complete
Definition at line 336 of file WorldStatePool.cc. Referenced by doReleaseResource().
returns true if the specified element of states has been marked completed
Definition at line 342 of file WorldStatePool.cc. Referenced by doneWritingState(), doUseResource(), getCurrentReadState(), and isUnread().
returns index of buffer in states to use for write request
Definition at line 221 of file WorldStatePool.h. Referenced by getCurrentWriteState(), and isUnread().
returns index of buffer in states to use for write request, stores index of corresponding entry of order in idx
Definition at line 350 of file WorldStatePool.cc.
called when access to an entry for writing is requested
Definition at line 387 of file WorldStatePool.cc. Referenced by doUseResource().
called when an write access to an entry is complete
Definition at line 428 of file WorldStatePool.cc. Referenced by doReleaseResource(), and getCurrentWriteState().
this shouldn't be called...
Member Data Documentation
indicies of entries, in the order they were written (i.e. corresponding value in frames should be monotonically increasing)
Definition at line 208 of file WorldStatePool.h. Referenced by getCurrentReadState(), getCurrentWriteState(), selectWriteState(), and WorldStatePool().
entries to hand out
Definition at line 230 of file WorldStatePool.h. Referenced by getCurrentReadState(), and getCurrentWriteState().
serial numbers of corresponding entries in states, set when writing begins, should be monotonically increasing relative to order (i.e. if you run through order and look at corresponding values in frames, should be monotonically increasing serial numbers)
Definition at line 232 of file WorldStatePool.h. Referenced by getCurrentWriteState(), isUnread(), selectWriteState(), and WorldStatePool().
flag set when a reader is blocking for writing to finish, until read is satisified
Definition at line 234 of file WorldStatePool.h. Referenced by doneReadingState(), getCurrentReadState(), selectWriteState(), and WorldStatePool().
count of writers in line for access (occurs when a writer is blocking on another writer of the same frame, or no other frames are free)
Definition at line 236 of file WorldStatePool.h. Referenced by doneWritingState(), getCurrentWriteState(), selectWriteState(), and WorldStatePool().
the status is intended as a bitfield to support communication between writers if they need to cooperatively fill out an entry The value is set to 0 before handing out to a writer with a new frame number Definition at line 239 of file WorldStatePool.h. Referenced by doReleaseResource(), doUseResource(), getCurrentWriteState(), and WorldStatePool().
this semaphore is set to positive value when writing begins, and then lowered to zero when complete A semaphore is used on "normal" systems because the MutexLock also implies a thread lock, which we actually don't want in this case because a different thread may complete the entry than the one which started it. Since Aperios does not allow multithreading, we don't have to worry about it there. As an aside, we could use this to store writing, but that would only be feasible if Aperios gave us semaphores. Bah. Definition at line 254 of file WorldStatePool.h. Referenced by doneWritingState(), getCurrentReadState(), getCurrentWriteState(), isComplete(), and WorldStatePool().
locks to be acquired before handing out corresponding states entry for writing
Definition at line 258 of file WorldStatePool.h. Referenced by doneWritingState(), and getCurrentWriteState().
lock on WorldStatePool's own members
Definition at line 260 of file WorldStatePool.h. Referenced by doneReadingState(), doneWritingState(), getCurrentReadState(), and getCurrentWriteState().
The documentation for this class was generated from the following files: |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:58:49 2007 by Doxygen 1.5.4 |