MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/event_mutex/main.cpp:52–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52int main(int argc, char* argv[])
53{
54 int ch, nthreads = 10;
55
56 while ((ch = getopt(argc, argv, "ht:n:S")) > 0)
57 {
58 switch (ch)
59 {
60 case 'h':
61 usage(argv[0]);
62 return 0;
63 case 't':
64 nthreads = atoi(optarg);
65 break;
66 case 'n':
67 __nloop = atoi(optarg);
68 break;
69 case 'S':
70 __show = true;
71 break;
72 default:
73 break;
74 }
75 }
76
77 acl::log::stdout_open(true);
78 acl::event_mutex lock(true);
79 lock.lock();
80 lock.lock();
81 lock.unlock();
82 lock.unlock();
83
84 printf("test ok, enter any key to continue ...");
85 fflush(stdout);
86 getchar();
87
88 std::vector<acl::thread*> threads;
89 for (int i = 0; i < nthreads; i++)
90 {
91 acl::thread* thr = new mythread(lock);
92 threads.push_back(thr);
93 thr->start();
94 }
95
96 for (std::vector<acl::thread*>::iterator it = threads.begin();
97 it != threads.end(); ++it)
98 {
99 (*it)->wait();
100 delete *it;
101 }
102
103 printf("\r\nAt last, count=%d\r\n", __count);
104 return 0;
105}

Callers

nothing calls this directly

Calls 9

beginMethod · 0.80
usageFunction · 0.70
getoptFunction · 0.50
lockMethod · 0.45
unlockMethod · 0.45
push_backMethod · 0.45
startMethod · 0.45
endMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…