blob: a6e597122a00412de4bef7c33067803cd7958f74 [file] [log] [blame]
Alexandre Lisionddd731e2014-01-31 11:50:08 -05001// Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
2//
3// This file is part of GNU uCommon C++.
4//
5// GNU uCommon C++ is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published
7// by the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GNU uCommon C++ is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
17
18#ifndef DEBUG
19#define DEBUG
20#endif
21
22#include <ucommon/ucommon.h>
23
24#include <stdio.h>
25
26using namespace UCOMMON_NAMESPACE;
27
28static unsigned count = 0;
29
30class testThread : public JoinableThread
31{
32public:
33 testThread() : JoinableThread() {};
34
35 void run(void) {
36 ++count;
37 ::sleep(2);
38 };
39};
40
41extern "C" int main()
42{
43 time_t now, later;
44 testThread *thr;
45
46 time(&now);
47 thr = new testThread();
48 start(thr);
49 Thread::sleep(10);
50 delete thr;
51 assert(count == 1);
52 time(&later);
53 assert(later >= now + 1);
54
55 time(&now);
56 TimedEvent evt;
57 evt.wait(2000);
58 time(&later);
59 assert(later >= now + 1);
60 return 0;
61}
62