mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ConditionVariable test
git-svn-id: svn://ultimatepp.org/upp/trunk@938 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6f8dcbb929
commit
1db0ee0ae5
4 changed files with 60 additions and 2 deletions
42
upptst/CVariable/CVariable.cpp
Normal file
42
upptst/CVariable/CVariable.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
ConditionVariable cv;
|
||||
Mutex mtx;
|
||||
int count;
|
||||
bool texit;
|
||||
|
||||
void WorkThread()
|
||||
{
|
||||
for(;;) {
|
||||
Mutex::Lock __(mtx);
|
||||
LOG("Before wait");
|
||||
if(texit) break;
|
||||
cv.Wait(mtx);
|
||||
LOG("After wait");
|
||||
if(texit) break;
|
||||
count++;
|
||||
}
|
||||
LOG("Exiting work thread");
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
Thread t[10];
|
||||
for(int i = 0; i < 10; i++)
|
||||
t[i].Run(callback(WorkThread));
|
||||
for(int i = 0; i < 1000; i++) {
|
||||
Mutex::Lock __(mtx);
|
||||
cv.Signal();
|
||||
}
|
||||
{
|
||||
Mutex::Lock __(mtx);
|
||||
texit = true;
|
||||
}
|
||||
texit = true;
|
||||
cv.Broadcast();
|
||||
for(int i = 0; i < 10; i++)
|
||||
t[i].Wait();
|
||||
LOG(count);
|
||||
}
|
||||
9
upptst/CVariable/CVariable.upp
Normal file
9
upptst/CVariable/CVariable.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
CVariable.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "MT";
|
||||
|
||||
4
upptst/CVariable/init
Normal file
4
upptst/CVariable/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _CVariable_icpp_init_stub
|
||||
#define _CVariable_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#endif
|
||||
|
|
@ -5,11 +5,14 @@ using namespace Upp;
|
|||
CONSOLE_APP_MAIN
|
||||
{
|
||||
ODBCSession session;
|
||||
session.Connect("DRIVER=SQL Server Native Client 10.0;SERVER=QUAD\\SQLEXPRESS;DATABASE=Holly;UID=test;PWD=koblih;");
|
||||
session.LogErrors();
|
||||
session.SetTrace();
|
||||
if(!session.Connect("DRIVER=SQL Server Native Client 10.0;SERVER=QUAD\\SQLEXPRESS;DATABASE=Holly;UID=test;PWD=koblih;"))
|
||||
return;
|
||||
LOG("Connected!");
|
||||
SQL = session;
|
||||
Sql sql;
|
||||
sql.Execute("select ID, TEXT, SINCE, TILL from SUBJECT_ATTR where SINCE > ?", Date(2009, 2, 20));
|
||||
sql.Execute("select AID, TEXT, SINCE, TILL from SUBJECT_ATTR where SINCE > ?", Date(2009, 2, 20));
|
||||
// sql.Execute("select ID, TEXT, SINCE, TILL from SUBJECT_ATTR where ID > ?", 1700);
|
||||
while(sql.Fetch()) {
|
||||
for(int i = 0; i < sql.GetColumns(); i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue