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

Function main

lib_acl_cpp/samples/flock/main.cpp:7–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#include <fcntl.h>
6
7int main(void)
8{
9 const char* log_file = "mylog.txt";
10 logger_open(log_file, "test", NULL);
11 acl::string buf(81920);
12 for (int i = 0; i < 81920; i++)
13 buf << 'X';
14 logger(buf.c_str());
15 logger_close();
16
17 acl::fstream fp;
18
19 if (fp.open("test.lock", O_RDWR, 0600) == false) {
20 printf("open file error\n");
21 getchar();
22 return (1);
23 }
24
25 acl::locker locker;
26
27 if (locker.open(fp.file_handle()) == false) {
28 printf("open lock error\n");
29 getchar();
30 return (1);
31 }
32 if (locker.lock() == true) {
33 printf("lock ok\n");
34 } else {
35 printf("lock error\n");
36 }
37
38 printf("enter any key to exit\n");
39 getchar();
40 return (0);
41}
42

Callers

nothing calls this directly

Calls 5

logger_openFunction · 0.85
file_handleMethod · 0.80
c_strMethod · 0.45
openMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…