00001 /* 00002 * File Name: condition.h 00003 */ 00004 00005 /* 00006 * This file is part of uds-plugin-pdf. 00007 * 00008 * uds-plugin-pdf is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * uds-plugin-pdf is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 /** 00023 * Copyright (C) 2008 iRex Technologies B.V. 00024 * All rights reserved. 00025 */ 00026 00027 #ifndef CONDITION_H 00028 #define CONDITION_H 00029 00030 #include <glib.h> 00031 00032 namespace pdf 00033 { 00034 00035 class Cond 00036 { 00037 public: 00038 Cond() 00039 : cond_(0) 00040 { 00041 cond_ = g_cond_new(); 00042 } 00043 00044 ~Cond() 00045 { 00046 g_cond_free(cond_); 00047 } 00048 00049 void signal() 00050 { 00051 // TODO. Do we have to lock here? 00052 g_cond_signal(cond_); 00053 } 00054 00055 void wait(GMutex* m) 00056 { 00057 if (m != 0) 00058 { 00059 g_cond_wait(cond_, m); 00060 } 00061 } 00062 00063 private: 00064 GCond* cond_; 00065 }; 00066 00067 }; 00068 00069 #endif 00070
1.6.2-20100208