Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

RTLMEM Class Reference

#include <rtlmem.hh>

Inheritance diagram for RTLMEM:

Inheritance graph
[legend]
Collaboration diagram for RTLMEM:

Collaboration graph
[legend]

Public Methods

 RTLMEM (char *bufline, char *procline, int set_to_server=0, int set_to_master=0)
virtual ~RTLMEM ()
CMS_STATUS read ()
CMS_STATUS peek ()
CMS_STATUS write (void *data)

Protected Attributes

rtlnml_t r
int key

Constructor & Destructor Documentation

RTLMEM::RTLMEM char *    bufline,
char *    procline,
int    set_to_server = 0,
int    set_to_master = 0
 

Definition at line 12 of file rtlmem.cc.

00013                                   :
00014 CMS (bufline, procline, set_to_server)
00015 {
00016   if (rtlnml_count == 0)
00017     {
00018       rtlnml_init ();
00019     }
00020   rtlnml_count++;
00021 #ifdef HAVE_RTAI
00022   if (sscanf (bufline, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %d", &key) != 1)
00023     {
00024       rcs_print_error ("SHMEM: Invalid configuration file format.\n");
00025       return;
00026     }
00027   r =
00028     rtainml_open (BufferName, ProcessName, NULL, size, is_local_master, key);
00029 #else
00030   r = rtlnml_open (BufferName, ProcessName, NULL, size, is_local_master);
00031 #endif
00032   if (NULL == r)
00033     {
00034       status = CMS_MISC_ERROR;
00035       return;
00036     }
00037   rtlnml_set_local_pointer (r, ((char *) data) + 8);
00038 }

RTLMEM::~RTLMEM   [virtual]
 

Definition at line 40 of file rtlmem.cc.

00041 {
00042   if (NULL != r)
00043     {
00044       rtlnml_close (r, BufferName);
00045     }
00046   rtlnml_count--;
00047   if (rtlnml_count == 0)
00048     {
00049       rtlnml_exit ();
00050     }
00051 }


Member Function Documentation

CMS_STATUS RTLMEM::read   [virtual]
 

Reimplemented from CMS.

Definition at line 55 of file rtlmem.cc.

Referenced by peek().

00056 {
00057   int split_read_count = 0;
00058   long type = rtlnml_read (r);
00059   if (type > 0)
00060     {
00061       ((NMLmsg *) data)->type = type;
00062       return (status = CMS_READ_OK);
00063     }
00064   if (type == RTLNML_READ_OLD)
00065     {
00066       return (status = CMS_READ_OLD);
00067     }
00068   if (type == RTLNML_SPLIT_READ_ERROR)
00069     {
00070       double start_time = etime ();
00071       double now = start_time;
00072       while ((now - start_time) < timeout || timeout < 0.0
00073              || split_read_count < 1)
00074         {
00075           long type = rtlnml_read (r);
00076           if (type > 0)
00077             {
00078               ((NMLmsg *) data)->type = type;
00079               return (status = CMS_READ_OK);
00080             }
00081           if (type == RTLNML_READ_OLD)
00082             {
00083               return (status = CMS_READ_OLD);
00084             }
00085           if (type == RTLNML_SPLIT_READ_ERROR)
00086             {
00087               split_read_count++;
00088             }
00089           else
00090             {
00091               return (status = CMS_MISC_ERROR);
00092             }
00093           now = etime ();
00094         }
00095       rcs_print_error
00096         ("Timedout after %d RTLNML_SPLIT_READ_ERRORs and %f seconds.\n",
00097          split_read_count, (etime () - start_time));
00098       return (status = CMS_TIMED_OUT);
00099     }
00100   return (status = CMS_MISC_ERROR);
00101 }

CMS_STATUS RTLMEM::peek   [virtual]
 

Reimplemented from CMS.

Definition at line 104 of file rtlmem.cc.

00105 {
00106   return read ();
00107 }

CMS_STATUS RTLMEM::write void *    data [virtual]
 

Reimplemented from CMS.

Definition at line 110 of file rtlmem.cc.

00111 {
00112   if (rtlnml_write
00113       (r, ((char *) data) + 8, ((NMLmsg *) data)->type,
00114        header.in_buffer_size) < 0)
00115     {
00116       return (status = CMS_MISC_ERROR);
00117     }
00118   return (status = CMS_WRITE_OK);
00119 }


Field Documentation

rtlnml_t RTLMEM::r [protected]
 

Definition at line 21 of file rtlmem.hh.

int RTLMEM::key [protected]
 

Definition at line 22 of file rtlmem.hh.


The documentation for this class was generated from the following files:
Generated on Sun Dec 2 15:59:17 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001