Main BLOGGER
Google
WWW THIS BLOG
Thursday, October 27, 2005
 
ACE Thread Mutex
// = LIBRARY
// tests
//
// = FILENAME
// Thread_Mutex_Test.cpp
//
// = DESCRIPTION
// This test illustrates the functionality of the
// ACE_Thread_Mutex. The test acquires and releases mutexes. No
// command line arguments are needed to run the test.
//
// = AUTHOR
// Prashant Jain and Doug Schmidt

Tuesday, October 25, 2005
 
A thorough C/C++ function pointer tutorial
http://www.newty.de/fpt/fpt.html#chapter2

Monday, October 24, 2005
 
ACE Message Queue Test

// Message_Queue_Test.cpp,v 4.59 2005/01/21 02:19:20 ossama Exp

 

// ============================================================================

//

// = LIBRARY

//    tests

//

// = FILENAME

//    Message_Queue_Test.cpp

//

// = DESCRIPTION

//      This is:

//      0) a test that ensures key ACE_Message_Queue features are

//         working properly, including timeouts and priorities.

//      1) a simple test of the ACE_Message_Queue that illustrates how to

//         use the forward and reverse iterators;

//      2) a simple performance measurement test for both single-threaded

//         (null synch) and thread-safe ACE_Message_Queues, and

//         ACE_Message_Queue_Vx, which wraps VxWorks message queues; and

//      3) a test/usage example of ACE_Message_Queue_Vx.

//

// = AUTHORS

//    Irfan Pyarali <irfan@cs.wustl.edu>,

//    David L. Levine <levine@cs.wustl.edu>, and

//    Douglas C. Schmidt <schmidt@vanderbilt.edu>

//

// ============================================================================

 


Sunday, October 23, 2005
 
ACE concurrency & related research

Friday, October 21, 2005
 
ACE Cached Virtual File system
1. ACE_Filecache_Handle

Abstraction over a real file. This is meant to be the entry point into the Cached Virtual Filesystem

2. ACE_Filecache

A hash table holding the information about entry point into the Cached Virtual Filesystem. On insertion, the reference count is incremented. On destruction, reference count is decremented

3.ACE_Filecache_Object

Abstraction over a real file. This is what the Virtual Filesystem contains. This class is not intended for general consumption. Please consult a physician before attempting to use this class


Examples: see ACE_WRAPPERS/apps/JAWS/server/IO.cpp

void
JAWS_Synch_IO::receive_file (const char *filename,
void *initial_data,
int initial_data_length,
int entire_length)
{
ACE_Filecache_Handle handle (filename, entire_length);

int result = handle.error ();

if (result == ACE_Filecache_Handle::ACE_SUCCESS)
{
...
ACE_OS::memcpy (handle.address (), initial_data, bytes_to_memcpy);
...
}
}


void
JAWS_Synch_IO::transmit_file (const char *filename,
const char *header,
int header_size,
const char *trailer,
int trailer_size)
{
ACE_Filecache_Handle handle (filename);

int result = handle.error ();

if (result == ACE_Filecache_Handle::ACE_SUCCESS)
{
ACE_SOCK_Stream stream;
...
(stream.send_n (handle.address (), handle.size ())
...
}

Thursday, October 20, 2005
 
Purify for memory leaks
1. Change Makefile, add /Fixed:No for link option

2. Instrument into rs.exe
purify /Replace=yes /Run=no rs

3. check library settings
Make sure the cache directory is in the %path%
for example: set path = %path%; C:\Program Files\Rational\PurifyPlus\cache

4. run rs.exe

5. Purify will be lanuched up automatically

6. Click "New Leaks" icon in the toolbar

7. Use right-button menu "quick filter" to filter un-related leaking or go to Filter Manager to customize filters.

Tips "using pushd and popd to fast-switching between paths"

Tips to purify Symphony Service From Michael Feiman
It should be working OK. Two major things to check:
1) Purify bin AND cache directory path should be accessible from the service environment.
If it's not in global path, it can be done by setting it to PATH environment in application profile for Service.
2) Start Purify itself BEFORE you start Symphony - the Purify IDE starts once and "globally", so
sometimes it can be a timing problem to start it from within service itself, but if it's already running, so
the new service just attaches to it.
Thanks
Michael

Monday, October 17, 2005
 
log4j XML property file example

1. Sample code

 

#define HAVE_XML

 

#ifdef HAVE_XML

  #include <log4cxx/xml/domconfigurator.h>

  using namespace log4cxx::xml;


Wednesday, October 05, 2005
 
C++ enum in distributed environment
http://www.cprogramming.com/tutorial/enum.html

1. enum is better than const in terms of type safety (to avoid unsencial value)
2. It is okay to convert an enum value to int but NOT vice versa.
3. It is better off using a string to convert a value to an enum value.
4. We can also use static_cast to typecast an int to an enum value.

Quoted from the above link

As already mentioned, you can't make the reverse assignment in C++ without using a typecast. There might be times when you do need to do this, but you'd like to avoid it as best you can. For instance, if you need to convert a user's input into an enumerated type, it would be a bad idea to just typecast the variable to an int:

wind_directions_t wind_direction = NO_WIND;

std::cin >> static_cast( wind_direction );

This would let the user input any value at all and, almost as bad, force the user to know the range of values that the enum could take on. A much better solution would be to shield the user from the enumeration by asking for a string and then validating the input by comparing it to the possible input strings to choose which constant to assign the enum. For instance,
std::cout << "Please enter NORTH, SOUTH, EAST, WEST, or NONE for our wind direction";
std::cout << std::endl;

string input_wind_dir;
cin >> wind_directions_t wind_dir;

if ( user_wind_dir == "NORTH" )
{
wind_dir = NORTH_WIND;
}
else if ( user_wind_dir == "SOUTH" )
{
wind_dir = SOUTH_WIND;
}
else if ( user_wind_dir == "EAST" )
{
wind_dir = EAST_WIND;
}
else if ( user_wind_dir == "WEST" )
{
wind_dir = WEST_WIND;
}
else if ( user_wind_dir == "NONE" )
{
wind_dir = NO_WIND;
}
else
{
std::cout << "That's not a valid direction!" << std::endl;
}



Powered by Blogger

Google
WWW THIS BLOG