-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate_utils.c
More file actions
50 lines (42 loc) · 1.73 KB
/
Copy pathstate_utils.c
File metadata and controls
50 lines (42 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* state_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dporhomo <dporhomo@student.42prague.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/06/13 15:58:26 by dporhomo #+# #+# */
/* Updated: 2026/06/15 13:37:57 by dporhomo ### ########.fr */
/* */
/* ************************************************************************** */
/* State variables: updates last_compile, compiles_done. */
#include "codexion.h"
/* Safe way to read last_compile */
long long read_last_compile(t_coder *coder)
{
long long time;
pthread_mutex_lock(&coder->prog->state_lock);
time = coder->last_compile;
pthread_mutex_unlock(&coder->prog->state_lock);
return (time);
}
void update_last_compile(t_coder *coder)
{
pthread_mutex_lock(&coder->prog->state_lock);
coder->last_compile = get_current_time();
pthread_mutex_unlock(&coder->prog->state_lock);
}
int read_compiles_done(t_coder *coder)
{
int done;
pthread_mutex_lock(&coder->prog->state_lock);
done = coder->compiles_done;
pthread_mutex_unlock(&coder->prog->state_lock);
return (done);
}
void increment_compiles_done(t_coder *coder)
{
pthread_mutex_lock(&coder->prog->state_lock);
coder->compiles_done++;
pthread_mutex_unlock(&coder->prog->state_lock);
}