MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / lock

Method lock

smallthinker/tools/run/run.cpp:328–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326 }
327
328 int lock() {
329 if (file) {
330# ifdef _WIN32
331 fd = _fileno(file);
332 hFile = (HANDLE) _get_osfhandle(fd);
333 if (hFile == INVALID_HANDLE_VALUE) {
334 fd = -1;
335
336 return 1;
337 }
338
339 OVERLAPPED overlapped = {};
340 if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, MAXDWORD, MAXDWORD,
341 &overlapped)) {
342 fd = -1;
343
344 return 1;
345 }
346# else
347 fd = fileno(file);
348 if (flock(fd, LOCK_EX | LOCK_NB) != 0) {
349 fd = -1;
350
351 return 1;
352 }
353# endif
354 }
355
356 return 0;
357 }
358
359 std::string to_string() {
360 fseek(file, 0, SEEK_END);

Callers 15

initMethod · 0.45
~vk_device_structMethod · 0.45
log_allocationMethod · 0.45
log_deallocationMethod · 0.45
ggml_vk_build_graphFunction · 0.45
ggml_vk_compute_forwardFunction · 0.45
ggml_vk_graph_cleanupFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected