Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phRequestDB.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission : 
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU General Public License for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 
00027 #include <phission.h>
00028 #include <phMessage.h>
00029 /* -------------------------------------------------------------------------- */
00030 /* phMessageNode: These are added into the phRequestList according to the
00031  * timestamp of the message. as replies come in, if the MessageNode doesn't
00032  * have as many replies as there are nodes in the system, then the reply node
00033  * is added to the particular MessageNode */
00034 /* -------------------------------------------------------------------------- */
00035 class phMessageNode : public phObject
00036 {
00037 private:
00038     phObjectList    m_list;
00039     phSemaphore     m_semaphore;
00040     phMessage       m_message;
00041 
00042 public:
00043     phMessageNode();
00044     ~phMessageNode();
00045 
00046     int         addReply        ( phMessage reply );
00047     uint32_t    getTotalReplies ( );
00048 
00049     int         setMessage      ( phMessage message );
00050     phMessage   &getMessage      ( );
00051 
00052     int         messageRelease  ( );
00053     int         messageWait     ( );
00054 
00055     void print(FILE *fd);
00056 };
00057 
00058 /* -------------------------------------------------------------------------- */
00059 /* phRequestList: The request list is made up of phMessageNode's for who is
00060  * going to get access to a particular resource. Each RequestList has an id
00061  * that is associated with the mutex/resource that is being accessed/locked
00062  * byt a Client */
00063 /* -------------------------------------------------------------------------- */
00064 class phRequestList : public phObject
00065 {
00066 private:
00067     phObjectList    m_list;
00068     uint32_t        m_id;
00069 
00070     uint32_t        m_clock;
00071 
00072 public:
00073     phRequestList(uint32_t id = phID_INVALID);
00074     ~phRequestList();
00075 
00076     uint32_t    tick(uint32_t compare_ts = phTIME_INVALID);
00077     uint32_t    getTimestamp();
00078     
00079     int         setId( uint32_t id );
00080     uint32_t    getId();
00081     
00082     phMessageNode *addMessage( phMessage message,
00083                                uint32_t total_nodes );
00084     int getTotalRequests( );
00085 
00086     phMessageNode *getHeadRequest ();
00087     int removeHeadRequest( );
00088     
00089     void print(FILE *fd, char *msg);
00090 };
00091 
00092 /* -------------------------------------------------------------------------- */
00093 /* phRequestDB: this object consists of group of phRequestLists. When a 
00094  * request comes in, the mutex-id of the request is the id of the 
00095  * phRequestList into which the request will be queued.
00096  * -------------------------------------------------------------------------- */
00097 /* The RequestDB doesn't need to be locked because the DB is only accessed
00098  * from within the Lamport System which is always locked before any of
00099  * this data is manipulated. */
00100 /* -------------------------------------------------------------------------- */
00101 class phRequestDB : public phObject
00102 {
00103 private:
00104     phObjectList m_list;
00105     
00106 public:
00107     phRequestDB();
00108     ~phRequestDB();
00109 
00110     phRequestList   *getRequestList     ( uint32_t id );
00111 
00112     uint32_t        getTotalLists();
00113 };
00114 




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:05 2007 for phission by  doxygen 1.4.4