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

tlock.cc File Reference

#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include "Logger.h"
#include "ObjLock.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Variables

Logger slog


Function Documentation

int main int  argc,
char **  argv
 

Definition at line 29 of file tlock.cc.

References ObjLock::lockExBlk(), ObjLock::lockExNoBlk(), ObjLock::lockShBlk(), and ObjLock::unlock().

00030 {
00031         fork();
00032         try {
00033                 class ObjLock ObjLock(string("lock_test.file"));
00034 
00035                 cout << "Trying get shared lock" << endl;
00036                 ObjLock.lockShBlk();
00037                 cout << "Shared gelockt." << endl;
00038 
00039                 sleep(10);
00040 
00041                 cout << "Trying unlock..." << endl;
00042                 ObjLock.unlock();
00043                 cout << "unlocked" << endl;
00044 
00045                 cout << "Trying get exclusive lock" << endl;
00046                 if (ObjLock.lockExNoBlk() == ObjLock::not_locked) {
00047                         cout << "get NO lock" << endl;
00048                 } else {
00049                         cout << "get lock" << endl;
00050                         ObjLock.unlock();
00051                 }
00052 
00053                 cout << "Trying get exclusive lock" << endl;
00054                 ObjLock.lockExBlk();
00055                 cout << "exlusive gelockt." << endl;
00056 
00057                 sleep(10);
00058 
00059                 cout << "Trying unlock..." << endl;
00060                 ObjLock.unlock();
00061                 cout << "unlocked" << endl;
00062         }
00063         catch(...) {
00064                 cout << "Error Handler" << endl;
00065                 perror("ErrorText");
00066                 exit(1);
00067         }
00068 
00069 }


Variable Documentation

Logger slog
 

Definition at line 25 of file tlock.cc.


Generated on Fri Aug 20 10:58:09 2004 for NewsCache by doxygen 1.3.6-20040222