⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chk_cond.cpp

📁 一个不错
💻 CPP
字号:
/* Copyright is licensed under GNU LGPL.                 by I.J.Wang 2003  Note: The check is few because no thread available yet.        Some check is performed in chk_thread1.cpp  Build: make chk_cond*/#include "wyret.h"#include "wycond.h"#include <iostream>#if WYCOND_VERSION!=31#error Test code is for WYCOND_VERSION 31#endif//// Test WyCond//static void t1(void){ WyRet r; WyCond cond; WyMutex mtx;  cond.signal();       // just to make sure this function exists cond.broadcast(); // // Chk err wait(WyLock&) // /* deprecate {  WyLock aa(mtx);  aa.unlock();  if((r=cond.wait(aa))!=Wym_EINVAL) {    WY_THROW(r);  } }*/ // // Check timedwait // {  WyLock aa(mtx);  WyTimeSpec t1=Wy::now()+WyTimeSpec(1,Wy_Nano());  if((r=cond.wait(aa,t1))!=Wym_ETIMEDOUT) {    WY_THROW(r);  }  WyTimeSpec t2=Wy::now();  if((t2-t1).abs()>WyTimeSpec(Wy_Second(),60000000)) {    WY_THROW( WyRet() );    // error > 0.06sec  }  /* deprecate  aa.unlock();  if((r=cond.wait(aa,t1))!=Wym_EINVAL) {    WY_THROW(r);  }*/ } // chk new {  WyCond *pcond= new WyCond;  delete pcond; }};static const WyStr chdr(                  "+---------------+\n"                  "| main() caught:|\n"                  "+---------------+\n");int main(void) throw()try { std::cout << "Checking wycond.cpp ...\n"; if(WyStr(WyCond::class_name)!="WyCond") {   WY_THROW( WyRet() ); } std::cout << "sizeof(WyCond)= " << sizeof(WyCond) << '\n'; t1();  std::cout << "Checked Ok\n"; return(0);}catch(const WyRet& e) { std::cerr << chdr.c_str() << Wy::wrd(e).c_str() << std::endl; return(-1);}catch(const std::exception& e) { std::cerr << chdr.c_str() << "std::exception" << std::endl; return(-1);}catch(...) { std::cerr << chdr.c_str() << "unknown unwind" << std::endl; return(-1);};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -