machinarium: introduce machinarium_stat()

This commit is contained in:
Dmitry Simonenko 2018-01-09 17:06:22 +03:00
parent 72e76438bd
commit 2d73372f03
4 changed files with 23 additions and 0 deletions

View File

@ -44,6 +44,10 @@ machinarium_init(void);
MACHINE_API void
machinarium_free(void);
MACHINE_API void
machinarium_stat(int *count_machine, int *count_coroutine,
int *count_coroutine_cache);
/* machine control */
MACHINE_API int64_t

View File

@ -21,6 +21,15 @@ void mm_machinemgr_free(mm_machinemgr_t *mgr)
pthread_spin_destroy(&mgr->lock);
}
int mm_machinemgr_count(mm_machinemgr_t *mgr)
{
int count;
pthread_spin_lock(&mgr->lock);
count = mgr->count;
pthread_spin_unlock(&mgr->lock);
return count;
}
void mm_machinemgr_add(mm_machinemgr_t *mgr, mm_machine_t *machine)
{
pthread_spin_lock(&mgr->lock);

View File

@ -19,6 +19,7 @@ struct mm_machinemgr
void mm_machinemgr_init(mm_machinemgr_t*);
void mm_machinemgr_free(mm_machinemgr_t*);
int mm_machinemgr_count(mm_machinemgr_t*);
void mm_machinemgr_add(mm_machinemgr_t*, mm_machine_t*);
void mm_machinemgr_delete(mm_machinemgr_t*, mm_machine_t*);
mm_machine_t*

View File

@ -45,3 +45,12 @@ machinarium_free(void)
mm_coroutine_cache_free(&machinarium.coroutine_cache);
mm_tls_free();
}
MACHINE_API void
machinarium_stat(int *count_machine, int *count_coroutine,
int *count_coroutine_cache)
{
*count_machine = mm_machinemgr_count(&machinarium.machine_mgr);
*count_coroutine = 0;
*count_coroutine_cache = 0;
}