29.12.2011 - license GPLv3
This commit is contained in:
23
main.cpp
23
main.cpp
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Test program
|
||||
Copyright (C) 2011 Ivan Pelipenko peri4@rambler.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pip.h"
|
||||
|
||||
|
||||
@@ -20,14 +39,14 @@ class MutexTest: public PIThread {
|
||||
public:
|
||||
MutexTest(): PIThread() {;}
|
||||
private:
|
||||
void run() {mutex_.lock(); if (m && cnt > 1) gm++; m = true; cout << " " << flush; if (cnt++ >= 128) stop(); msleep(20); mutex_.unlock();}
|
||||
void run() {mutex_.lock(); if (m && cnt > 1) gm++; m = true; cout << " " << flush; if (cnt++ >= 128) stop(); msleep(1); mutex_.unlock();}
|
||||
};
|
||||
|
||||
class MutexTest2: public PIThread {
|
||||
public:
|
||||
MutexTest2(): PIThread() {;}
|
||||
private:
|
||||
void run() {mutex_.lock(); if (!m && cnt > 1) gm++; m = false; cout << "|" << flush; if (cnt++ >= 128) stop(); msleep(20); mutex_.unlock();}
|
||||
void run() {mutex_.lock(); if (!m && cnt > 1) gm++; m = false; cout << "|" << flush; if (cnt++ >= 128) stop(); msleep(1); mutex_.unlock();}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user