00001 #ifndef __J2K__Mutex_HPP__
00002 #define __J2K__Mutex_HPP__
00003
00004 #include <j2k/Fred/QNX/System.hpp>
00005
00006 #define MUTEX_DATA_TYPE 125
00007
00008 class Mutex {
00009 public:
00010 int Identification;
00011
00012 int isBlocked() {
00013 return blocked;
00014 }
00015
00016 void Block() {
00017 blocked = 1;
00018 buffer = current;
00019 }
00020
00021 void UnBlock() {
00022 current = buffer;
00023 blocked = 0;
00024 }
00025
00026 void* Read() {
00027 return current;
00028 }
00029
00030 void Write( void* p ) {
00031 if ( blocked ) {
00032 buffer = p;
00033 } else {
00034 current = p;
00035 }
00036 }
00037
00038
00039 Mutex(void* data)
00040 : Identification( MUTEX_DATA_TYPE ),
00041 blocked( 0 ),
00042 current( data ),
00043 buffer( data ) { }
00044
00045 private:
00046 int blocked;
00047 void* buffer;
00048 void* current;
00049 };
00050
00051 #endif