Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
lektor
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Kubat
lektor
Validations
2ec50820
Vérifiée
Valider
2ec50820
rédigé
5 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Don't use mthread for the moment, use to much cpu
parent
2caaa0bc
Aucune branche associée trouvée
Branches contenant la validation
Aucune étiquette associée trouvée
Étiquettes contenant la validation
1 requête de fusion
!67
Resolve "Thread pool"
Modifications
4
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
4 fichiers modifiés
inc/lektor/thread.h
+4
-4
4 ajouts, 4 suppressions
inc/lektor/thread.h
src/main/server.c
+1
-1
1 ajout, 1 suppression
src/main/server.c
src/repo/async.c
+9
-9
9 ajouts, 9 suppressions
src/repo/async.c
src/thread.c
+14
-14
14 ajouts, 14 suppressions
src/thread.c
avec
28 ajouts
et
28 suppressions
inc/lektor/thread.h
+
4
−
4
Voir le fichier @
2ec50820
#pragma once
#pragma once
#include
<lektor/define.h>
#include
<lektor/define.h>
#include
<
mthread/m
thread.h>
#include
<
p
thread.h>
#include
<sys/types.h>
#include
<sys/types.h>
struct
poller_thread
{
struct
poller_thread
{
...
@@ -9,16 +9,16 @@ struct poller_thread {
...
@@ -9,16 +9,16 @@ struct poller_thread {
volatile
unsigned
int
input_len
;
volatile
unsigned
int
input_len
;
volatile
unsigned
int
input_size
;
volatile
unsigned
int
input_size
;
volatile
void
*
volatile
*
volatile
input_cells
;
volatile
void
*
volatile
*
volatile
input_cells
;
m
thread_mutex_t
input_lock
;
p
thread_mutex_t
input_lock
;
m
thread_t
th
;
p
thread_t
th
;
unsigned
int
initial_size
;
unsigned
int
initial_size
;
/* The output pool. */
/* The output pool. */
volatile
unsigned
int
output_len
;
volatile
unsigned
int
output_len
;
volatile
unsigned
int
output_size
;
volatile
unsigned
int
output_size
;
volatile
void
*
volatile
*
volatile
output_cells
;
volatile
void
*
volatile
*
volatile
output_cells
;
m
thread_mutex_t
output_lock
;
p
thread_mutex_t
output_lock
;
};
};
struct
poller_thread_arg
{
struct
poller_thread_arg
{
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/main/server.c
+
1
−
1
Voir le fichier @
2ec50820
...
@@ -57,7 +57,7 @@ main(int argc, char *argv[])
...
@@ -57,7 +57,7 @@ main(int argc, char *argv[])
normal_launch:
normal_launch:
LOG_INFO
(
"Lektor launched by user %s (shell: %s, home: %s)"
,
pw
->
pw_name
,
pw
->
pw_shell
,
pw
->
pw_dir
);
LOG_INFO
(
"Lektor launched by user %s (shell: %s, home: %s)"
,
pw
->
pw_name
,
pw
->
pw_shell
,
pw
->
pw_dir
);
mthread_init
();
//
mthread_init();
return
lkt_listen
();
return
lkt_listen
();
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
src/repo/async.c
+
9
−
9
Voir le fichier @
2ec50820
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
static
struct
poller_thread
repo_thread
;
static
struct
poller_thread
repo_thread
;
static
m
thread_mutex_t
mtx
=
M
THREAD_MUTEX_INITIALIZER
;
static
p
thread_mutex_t
mtx
=
P
THREAD_MUTEX_INITIALIZER
;
static
volatile
int
init
=
0
;
static
volatile
int
init
=
0
;
static
volatile
int
stop
=
0
;
static
volatile
int
stop
=
0
;
static
volatile
int
all_json
=
0
;
static
volatile
int
all_json
=
0
;
...
@@ -22,14 +22,14 @@ int
...
@@ -22,14 +22,14 @@ int
repo_join_thread
(
void
)
repo_join_thread
(
void
)
{
{
int
ret
=
1
;
int
ret
=
1
;
RETURN_IF
(
m
thread_mutex_lock
(
&
mtx
),
"Failed to lock mutex"
,
3
);
RETURN_IF
(
p
thread_mutex_lock
(
&
mtx
),
"Failed to lock mutex"
,
3
);
GOTO_UNLESS
(
init
,
"Repo thread no launched, can't join"
,
error
);
GOTO_UNLESS
(
init
,
"Repo thread no launched, can't join"
,
error
);
stop
=
1
;
stop
=
1
;
GOTO_IF
(
m
thread_join
(
repo_thread
.
th
,
NULL
),
"Failed to join repo thread"
,
error
);
GOTO_IF
(
p
thread_join
(
repo_thread
.
th
,
NULL
),
"Failed to join repo thread"
,
error
);
LOG_INFO
(
"%s"
,
"repo thread joined"
);
LOG_INFO
(
"%s"
,
"repo thread joined"
);
ret
=
0
;
ret
=
0
;
error:
error:
RETURN_IF
(
m
thread_mutex_unlock
(
&
mtx
),
"Failed to unlock mutex"
,
3
);
RETURN_IF
(
p
thread_mutex_unlock
(
&
mtx
),
"Failed to unlock mutex"
,
3
);
return
ret
;
return
ret
;
}
}
...
@@ -113,7 +113,7 @@ __repo_thread_function(struct poller_thread_arg *arg)
...
@@ -113,7 +113,7 @@ __repo_thread_function(struct poller_thread_arg *arg)
LOG_INFO
(
"%s"
,
"Starting the repo thread"
);
LOG_INFO
(
"%s"
,
"Starting the repo thread"
);
for
(;;)
{
for
(;;)
{
GOTO_IF
(
m
thread_mutex_lock
(
&
mtx
),
"Failed to lock mutex"
,
end_loop
);
GOTO_IF
(
p
thread_mutex_lock
(
&
mtx
),
"Failed to lock mutex"
,
end_loop
);
if
(
all_json
)
{
if
(
all_json
)
{
repo_get_alljson_sync
(
repo
,
&
json
);
repo_get_alljson_sync
(
repo
,
&
json
);
...
@@ -122,7 +122,7 @@ __repo_thread_function(struct poller_thread_arg *arg)
...
@@ -122,7 +122,7 @@ __repo_thread_function(struct poller_thread_arg *arg)
}
}
if
(
stop
)
{
if
(
stop
)
{
if
(
m
thread_mutex_unlock
(
&
mtx
))
if
(
p
thread_mutex_unlock
(
&
mtx
))
LOG_ERROR
(
"Failed to unlock mutex: %s"
,
strerror
(
errno
));
LOG_ERROR
(
"Failed to unlock mutex: %s"
,
strerror
(
errno
));
break
;
break
;
}
}
...
@@ -178,7 +178,7 @@ try_later:
...
@@ -178,7 +178,7 @@ try_later:
LOG_ERROR
(
"%s"
,
"Failed to get the head of the input list"
);
LOG_ERROR
(
"%s"
,
"Failed to get the head of the input list"
);
end_loop:
end_loop:
mthrea
d_yield
();
sche
d_yield
();
sleep
(
1
);
sleep
(
1
);
}
}
...
@@ -226,8 +226,8 @@ err:
...
@@ -226,8 +226,8 @@ err:
inline
int
inline
int
repo_get_allid_async
(
void
)
repo_get_allid_async
(
void
)
{
{
RETURN_IF
(
m
thread_mutex_lock
(
&
mtx
),
"Failed to lock mutex"
,
3
);
RETURN_IF
(
p
thread_mutex_lock
(
&
mtx
),
"Failed to lock mutex"
,
3
);
all_json
=
1
;
all_json
=
1
;
RETURN_IF
(
m
thread_mutex_unlock
(
&
mtx
),
"Failed to lock mutex"
,
3
);
RETURN_IF
(
p
thread_mutex_unlock
(
&
mtx
),
"Failed to lock mutex"
,
3
);
return
0
;
return
0
;
}
}
Ce diff est replié.
Cliquez pour l'agrandir.
src/thread.c
+
14
−
14
Voir le fichier @
2ec50820
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include
<common/common.h>
#include
<common/common.h>
#include
<lektor/thread.h>
#include
<lektor/thread.h>
#include
<
mthread/m
thread.h>
#include
<
p
thread.h>
#include
<sys/types.h>
#include
<sys/types.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<errno.h>
#include
<errno.h>
...
@@ -29,8 +29,8 @@ int
...
@@ -29,8 +29,8 @@ int
lkt_th_new
(
struct
poller_thread
*
th
,
unsigned
int
init_sizes
,
lkt_th_new
(
struct
poller_thread
*
th
,
unsigned
int
init_sizes
,
void
*
(
*
func
)(
struct
poller_thread_arg
*
),
void
*
args
)
void
*
(
*
func
)(
struct
poller_thread_arg
*
),
void
*
args
)
{
{
m
thread_mutex_t
mtx1
=
M
THREAD_MUTEX_INITIALIZER
;
p
thread_mutex_t
mtx1
=
P
THREAD_MUTEX_INITIALIZER
;
m
thread_mutex_t
mtx2
=
M
THREAD_MUTEX_INITIALIZER
;
p
thread_mutex_t
mtx2
=
P
THREAD_MUTEX_INITIALIZER
;
struct
poller_thread
th_
=
{
struct
poller_thread
th_
=
{
.
initial_size
=
init_sizes
,
.
initial_size
=
init_sizes
,
.
input_lock
=
mtx1
,
.
input_lock
=
mtx1
,
...
@@ -52,7 +52,7 @@ lkt_th_new(struct poller_thread *th, unsigned int init_sizes,
...
@@ -52,7 +52,7 @@ lkt_th_new(struct poller_thread *th, unsigned int init_sizes,
__args
->
arg
=
args
;
__args
->
arg
=
args
;
__args
->
arg
->
self
=
th
;
__args
->
arg
->
self
=
th
;
if
(
!
m
thread_create
(
&
(
th
->
th
),
NULL
,
__start
,
__args
))
{
if
(
!
p
thread_create
(
&
(
th
->
th
),
NULL
,
__start
,
__args
))
{
LOG_INFO_SCT
(
"THREAD"
,
"%s"
,
"Create a new poller thread"
);
LOG_INFO_SCT
(
"THREAD"
,
"%s"
,
"Create a new poller thread"
);
return
0
;
return
0
;
}
}
...
@@ -75,7 +75,7 @@ out_of_memory:
...
@@ -75,7 +75,7 @@ out_of_memory:
int
int
lkt_th_join
(
struct
poller_thread
*
th
,
void
**
ret
)
lkt_th_join
(
struct
poller_thread
*
th
,
void
**
ret
)
{
{
int
sta
=
m
thread_join
(
th
->
th
,
ret
);
int
sta
=
p
thread_join
(
th
->
th
,
ret
);
if
(
sta
)
if
(
sta
)
LOG_ERROR
(
"%s"
,
"Failed to join thread"
);
LOG_ERROR
(
"%s"
,
"Failed to join thread"
);
...
@@ -94,12 +94,12 @@ lkt_th_join(struct poller_thread *th, void **ret)
...
@@ -94,12 +94,12 @@ lkt_th_join(struct poller_thread *th, void **ret)
static
inline
int
static
inline
int
th_append
(
unsigned
int
*
len
,
unsigned
int
*
size
,
void
***
cells
,
th_append
(
unsigned
int
*
len
,
unsigned
int
*
size
,
void
***
cells
,
m
thread_mutex_t
*
lock
,
void
*
ptr
)
p
thread_mutex_t
*
lock
,
void
*
ptr
)
{
{
void
*
new
;
void
*
new
;
int
ret
=
0
;
int
ret
=
0
;
GOTO_IF
(
m
thread_mutex_lock
(
lock
),
"Failed to lock"
,
end
);
GOTO_IF
(
p
thread_mutex_lock
(
lock
),
"Failed to lock"
,
end
);
if
(
*
len
==
*
size
)
{
if
(
*
len
==
*
size
)
{
new
=
realloc
((
void
*
)
*
cells
,
(
*
len
+
*
size
)
*
sizeof
(
void
*
));
new
=
realloc
((
void
*
)
*
cells
,
(
*
len
+
*
size
)
*
sizeof
(
void
*
));
...
@@ -117,16 +117,16 @@ th_append(unsigned int *len, unsigned int *size, void ***cells,
...
@@ -117,16 +117,16 @@ th_append(unsigned int *len, unsigned int *size, void ***cells,
(
*
cells
)[(
*
len
)
++
]
=
ptr
;
(
*
cells
)[(
*
len
)
++
]
=
ptr
;
ret
=
0
;
ret
=
0
;
end:
end:
RETURN_IF
(
m
thread_mutex_unlock
(
lock
),
"Failed to lock"
,
1
);
RETURN_IF
(
p
thread_mutex_unlock
(
lock
),
"Failed to lock"
,
1
);
return
ret
;
return
ret
;
}
}
static
inline
int
static
inline
int
th_pop
(
unsigned
int
*
len
,
void
**
cells
,
m
thread_mutex_t
*
lock
,
void
**
ptr
)
th_pop
(
unsigned
int
*
len
,
void
**
cells
,
p
thread_mutex_t
*
lock
,
void
**
ptr
)
{
{
int
ret
=
1
;
int
ret
=
1
;
GOTO_IF
(
m
thread_mutex_lock
(
lock
),
"Failed to lock"
,
end
);
GOTO_IF
(
p
thread_mutex_lock
(
lock
),
"Failed to lock"
,
end
);
if
(
*
len
>
0
)
if
(
*
len
>
0
)
*
ptr
=
cells
[
--
(
*
len
)];
*
ptr
=
cells
[
--
(
*
len
)];
...
@@ -135,15 +135,15 @@ th_pop(unsigned int *len, void **cells, mthread_mutex_t *lock, void **ptr)
...
@@ -135,15 +135,15 @@ th_pop(unsigned int *len, void **cells, mthread_mutex_t *lock, void **ptr)
ret
=
0
;
ret
=
0
;
end:
end:
RETURN_IF
(
m
thread_mutex_unlock
(
lock
),
"Failed to lock"
,
1
);
RETURN_IF
(
p
thread_mutex_unlock
(
lock
),
"Failed to lock"
,
1
);
return
ret
;
return
ret
;
}
}
static
inline
int
static
inline
int
th_head
(
unsigned
int
len
,
void
**
cells
,
m
thread_mutex_t
*
lock
,
void
**
ptr
)
th_head
(
unsigned
int
len
,
void
**
cells
,
p
thread_mutex_t
*
lock
,
void
**
ptr
)
{
{
int
ret
=
1
;
int
ret
=
1
;
GOTO_IF
(
m
thread_mutex_lock
(
lock
),
"Failed to lock"
,
end
);
GOTO_IF
(
p
thread_mutex_lock
(
lock
),
"Failed to lock"
,
end
);
if
(
len
>
0
)
if
(
len
>
0
)
*
ptr
=
cells
[
len
-
1
];
*
ptr
=
cells
[
len
-
1
];
...
@@ -152,7 +152,7 @@ th_head(unsigned int len, void **cells, mthread_mutex_t *lock, void **ptr)
...
@@ -152,7 +152,7 @@ th_head(unsigned int len, void **cells, mthread_mutex_t *lock, void **ptr)
ret
=
0
;
ret
=
0
;
end:
end:
RETURN_IF
(
m
thread_mutex_unlock
(
lock
),
"Failed to lock"
,
1
);
RETURN_IF
(
p
thread_mutex_unlock
(
lock
),
"Failed to lock"
,
1
);
return
ret
;
return
ret
;
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter