/////////////////////////////////////////////////////////////////////// // lockingPtr.cpp - provides serialized access to class objects // // ver 1.1 // // Language: Visual C++, ver 6.0 // // Platform: Dell Dimension 8100, Win2000, SP 2 // // Application: CSE691 - Useful for projects #2 and #3 // // Author: Jim Fawcett, CST 2-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////////////// #include #include "lockingPtr.h" using namespace std; #ifdef TEST_LOCKINGPTR class dummySharedObject { public: dummySharedObject(int value) : _val(value) { } int& value() { return _val; } private: int _val; }; void main() { cout << "\n Demo Constr'n and Destr'n of Temporary lockingPtr Object " << "\n ==========================================================\n"; Mutex mtx; dummySharedObject dso(5); cout << "\n before accessing dummySharedObject with lockedPtr" << endl; // create and use temporary object - will be destroyed immediately int temp = lockingPtr(dso,mtx)->value(); cout << "\n\n retrieved value = " << temp << endl; cout << '\n'; } #endif