diff --git a/upptst/CVariable/CVariable.cpp b/upptst/CVariable/CVariable.cpp new file mode 100644 index 000000000..92e207d76 --- /dev/null +++ b/upptst/CVariable/CVariable.cpp @@ -0,0 +1,42 @@ +#include + +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); +} diff --git a/upptst/CVariable/CVariable.upp b/upptst/CVariable/CVariable.upp new file mode 100644 index 000000000..31d5c3629 --- /dev/null +++ b/upptst/CVariable/CVariable.upp @@ -0,0 +1,9 @@ +uses + Core; + +file + CVariable.cpp; + +mainconfig + "" = "MT"; + diff --git a/upptst/CVariable/init b/upptst/CVariable/init new file mode 100644 index 000000000..2f4bb85e3 --- /dev/null +++ b/upptst/CVariable/init @@ -0,0 +1,4 @@ +#ifndef _CVariable_icpp_init_stub +#define _CVariable_icpp_init_stub +#include "Core/init" +#endif diff --git a/upptst/odbctst/odbctst.cpp b/upptst/odbctst/odbctst.cpp index 7fd2dd760..be163b61e 100644 --- a/upptst/odbctst/odbctst.cpp +++ b/upptst/odbctst/odbctst.cpp @@ -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++) {