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

Function main

lib_acl_cpp/samples/tbox/tbox.cpp:32–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32int main(int argc, char* argv[])
33{
34 int max = 50000000, ch;
35 acl::string type("tbox");
36 acl::box<int>* box;
37
38 while ((ch = getopt(argc, argv, "ht:n:")) > 0) {
39 switch (ch) {
40 case 'h':
41 usage(argv[0]);
42 return 0;
43 case 't':
44 type = optarg;
45 break;
46 case 'n':
47 max = atoi(optarg);
48 break;
49 default:
50 break;
51 }
52 }
53
54 if (type == "tbox") {
55 box = new acl::tbox<int>;
56 } else if (type == "tbox_array") {
57 box = new acl::tbox_array<int>;
58 } else if (type == "mbox") {
59 box = new acl::mbox<int>;
60 } else {
61 printf("unknown type=%s\r\n", type.c_str());
62 return 1;
63 }
64
65 producer thr(*box, max);
66 thr.start();
67
68 for (int i = 0; i < max; i++) {
69 int* n = box->pop();
70 assert(*n == i);
71 delete n;
72 }
73
74 printf("All over, box type=%s, max=%d\r\n", type.c_str(), max);
75 thr.wait();
76
77 delete box;
78 return 0;
79}

Callers

nothing calls this directly

Calls 6

usageFunction · 0.70
getoptFunction · 0.50
c_strMethod · 0.45
startMethod · 0.45
popMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…