ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
time.c File Reference

Time functions for WASM/Emscripten. More...

Go to the source code of this file.

Functions

uint64_t platform_get_time_ms (void)
 
uint64_t platform_get_time_us (void)
 
void platform_sleep_ms (unsigned int ms)
 
void platform_sleep_us (unsigned int us)
 
uint64_t platform_get_monotonic_time_ns (void)
 
uint64_t platform_get_monotonic_time_us (void)
 

Detailed Description

Time functions for WASM/Emscripten.

Definition in file platform/wasm/time.c.

Function Documentation

◆ platform_get_monotonic_time_ns()

uint64_t platform_get_monotonic_time_ns ( void  )

Definition at line 38 of file platform/wasm/time.c.

38 {
39 struct timespec ts;
40 clock_gettime(CLOCK_MONOTONIC, &ts);
41 return (uint64_t)ts.tv_sec * 1000000000ULL + (uint64_t)ts.tv_nsec;
42}

◆ platform_get_monotonic_time_us()

uint64_t platform_get_monotonic_time_us ( void  )

Definition at line 44 of file platform/wasm/time.c.

44 {
45 struct timespec ts;
46 clock_gettime(CLOCK_MONOTONIC, &ts);
47 return (uint64_t)ts.tv_sec * 1000000ULL + (uint64_t)ts.tv_nsec / 1000ULL;
48}

Referenced by discovery_session_process(), platform_print_backtrace_symbols(), server_main(), server_status_update(), terminal_screen_render(), and webrtc_is_gathering_timed_out().

◆ platform_get_time_ms()

uint64_t platform_get_time_ms ( void  )

Definition at line 12 of file platform/wasm/time.c.

12 {
13 struct timeval tv;
14 gettimeofday(&tv, NULL);
15 return (uint64_t)tv.tv_sec * 1000 + (uint64_t)tv.tv_usec / 1000;
16}

◆ platform_get_time_us()

uint64_t platform_get_time_us ( void  )

Definition at line 18 of file platform/wasm/time.c.

18 {
19 struct timeval tv;
20 gettimeofday(&tv, NULL);
21 return (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec;
22}

◆ platform_sleep_ms()

void platform_sleep_ms ( unsigned int  ms)

Definition at line 24 of file platform/wasm/time.c.

24 {
25 struct timespec ts;
26 ts.tv_sec = ms / 1000;
27 ts.tv_nsec = (ms % 1000) * 1000000;
28 nanosleep(&ts, NULL);
29}

Referenced by acds_server_shutdown(), client_receive_thread(), disconnect_client_for_bad_data(), discovery_session_process(), discovery_tui_select(), and session_client_like_run().

◆ platform_sleep_us()

void platform_sleep_us ( unsigned int  us)

Definition at line 31 of file platform/wasm/time.c.

31 {
32 struct timespec ts;
33 ts.tv_sec = us / 1000000;
34 ts.tv_nsec = (us % 1000000) * 1000;
35 nanosleep(&ts, NULL);
36}

Referenced by audio_cleanup(), audio_stop_thread(), capture_stop_thread(), client_send_thread_func(), discovery_session_process(), platform_write_all(), protocol_stop_connection(), remove_client(), server_connection_establish(), session_capture_create(), session_render_loop(), stats_logger_thread(), and time_sleep_ns().