Титульная страница | Пространства имен | Алфавитный указатель | Классы | Файлы | Члены пространства имен | Члены классов | Описания | Примеры

sample/mutex/main.cpp

/* threads_1: Multithreading support library Yauheni A. Akhotnikau (C) 2002-2003 eao197@yahoo.com ------------------------------------------------- Permission is granted to anyone to use this software for any purpose on any computer system, and to redistribute it freely, subject to the following restrictions: 1. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 2. The origin of this software must not be misrepresented, either by explicit claim or by omission. 3. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. ------------------------------------------------- */ #include <iostream> #include <time.h> #include <cpp_util_2/h/defs.hpp> #include <threads_1/h/threads.hpp> int main() { threads_1::mutex_sem_t mutex; std::cout << "Start" << std::endl; clock_t start, finish; start = clock(); for( int i = 0; i != 1000000; ++i ) { mutex.lock(); mutex.release(); } finish = clock(); std::cout << "Finish" << std::endl; std::cout << "Time: " << finish - start << std::endl; return 0; }
00001 /* 00002 00003 threads_1: Multithreading support library 00004 Yauheni A. Akhotnikau (C) 2002-2003 00005 eao197@yahoo.com 00006 ------------------------------------------------- 00007 00008 Permission is granted to anyone to use this software for any purpose on any 00009 computer system, and to redistribute it freely, subject to the following 00010 restrictions: 00011 00012 1. This software is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00015 00016 2. The origin of this software must not be misrepresented, either by 00017 explicit claim or by omission. 00018 00019 3. Altered versions must be plainly marked as such, and must not be 00020 misrepresented as being the original software. 00021 00022 ------------------------------------------------- 00023 00024 */ 00025 #include <iostream> 00026 00027 #include <time.h> 00028 00029 #include <cpp_util_2/h/defs.hpp> 00030 00031 #include <threads_1/h/threads.hpp> 00032 00033 int 00034 main() 00035 { 00036 threads_1::mutex_sem_t mutex; 00037 00038 std::cout << "Start" << std::endl; 00039 00040 clock_t start, finish; 00041 start = clock(); 00042 00043 for( int i = 0; i != 1000000; ++i ) 00044 { 00045 mutex.lock(); 00046 mutex.release(); 00047 } 00048 00049 finish = clock(); 00050 00051 std::cout << "Finish" << std::endl; 00052 00053 std::cout << "Time: " << finish - start << std::endl; 00054 00055 return 0; 00056 } 00057

Документация по threads_1. Последние изменения: Wed Aug 4 06:46:00 2004. Создано системой doxygen 1.3.7
Hosted by uCoz