00001 #ifndef __J2K__Mailbox_HPP__
00002 #define __J2K__Mailbox_HPP__
00003
00004
00005
00006
00007
00008
00009 #include <j2k/Fred/Standard.hpp>
00010 #include <j2k/445/DList_pchar.hpp>
00011 #include <j2k/445/Posix/Mutex.hpp>
00012
00013 class Mailbox {
00014 public:
00015 Mailbox() {
00016 queue = new DList_pchar();
00017 }
00018
00019 void send( char* item ) {
00020 mutex0.lock();
00021 queue.append( item );
00022 mutex0.unlock();
00023 }
00024
00025 char* receive() {
00026 char* item = NULL;
00027 mutex0.lock();
00028 if ( queue.size() != 0 ) {
00029 queue.setFirst();
00030 item = queue.remove();
00031 }
00032 mutex0.unlock();
00033 return item;
00034 }
00035
00036 private:
00037
00038 Mutex mutex0;
00039 DList_pchar* queue;
00040 };
00041
00042 #endif