mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-10 01:40:26 +00:00
FS-10167: Fixed bug in windows test_thread_pools test related to the thread pool itself and ks_q cleanup
This commit is contained in:
parent
7fd6a2c119
commit
b41a847b9d
@ -44,6 +44,7 @@ KS_BEGIN_EXTERN_C
|
|||||||
#define ks_time_nsec(time) (((time) % KS_USEC_PER_SEC) * 1000)
|
#define ks_time_nsec(time) (((time) % KS_USEC_PER_SEC) * 1000)
|
||||||
#define ks_sleep_ms(_t) ks_sleep(_t * 1000)
|
#define ks_sleep_ms(_t) ks_sleep(_t * 1000)
|
||||||
|
|
||||||
|
KS_DECLARE(void) ks_time_init(void);
|
||||||
KS_DECLARE(ks_time_t) ks_time_now(void);
|
KS_DECLARE(ks_time_t) ks_time_now(void);
|
||||||
KS_DECLARE(ks_time_t) ks_time_now_sec(void);
|
KS_DECLARE(ks_time_t) ks_time_now_sec(void);
|
||||||
KS_DECLARE(void) ks_sleep(ks_time_t microsec);
|
KS_DECLARE(void) ks_sleep(ks_time_t microsec);
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007,2008 Mij <mij@bitchx.it>
|
* Copyright (c) 2007,2008 Mij <mij@bitchx.it>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SimCList library. See http://mij.oltrelinux.com/devel/simclist
|
* SimCList library. See http://mij.oltrelinux.com/devel/simclist
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef SIMCLIST_H
|
#ifndef SIMCLIST_H
|
||||||
@ -33,11 +33,11 @@ extern "C" {
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifndef SIMCLIST_NO_DUMPRESTORE
|
#ifndef SIMCLIST_NO_DUMPRESTORE
|
||||||
#ifndef _WIN32
|
# ifndef _WIN32
|
||||||
#include <sys/time.h> /* list_dump_info_t's struct timeval */
|
# include <sys/time.h> /* list_dump_info_t's struct timeval */
|
||||||
#else
|
# else
|
||||||
#include <time.h>
|
# include <time.h>
|
||||||
#endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ extern "C" {
|
|||||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||||
/* "inline" and "restrict" are keywords */
|
/* "inline" and "restrict" are keywords */
|
||||||
#else
|
#else
|
||||||
#define inline /* inline */
|
# define inline /* inline */
|
||||||
#define restrict /* restrict */
|
# define restrict /* restrict */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* It is responsability of the function to handle possible NULL values.
|
* It is responsability of the function to handle possible NULL values.
|
||||||
*/
|
*/
|
||||||
typedef int (*element_comparator) (const void *a, const void *b);
|
typedef int(*element_comparator)(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a seeker of elements.
|
* a seeker of elements.
|
||||||
@ -91,7 +91,7 @@ extern "C" {
|
|||||||
* It is responsability of the function to handle possible NULL values in any
|
* It is responsability of the function to handle possible NULL values in any
|
||||||
* argument.
|
* argument.
|
||||||
*/
|
*/
|
||||||
typedef int (*element_seeker) (const void *el, const void *indicator);
|
typedef int(*element_seeker)(const void *el, const void *indicator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* an element lenght meter.
|
* an element lenght meter.
|
||||||
@ -102,7 +102,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* It is responsability of the function to handle possible NULL values.
|
* It is responsability of the function to handle possible NULL values.
|
||||||
*/
|
*/
|
||||||
typedef size_t (*element_meter) (const void *el);
|
typedef size_t(*element_meter)(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a function computing the hash of elements.
|
* a function computing the hash of elements.
|
||||||
@ -113,7 +113,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* It is responsability of the function to handle possible NULL values.
|
* It is responsability of the function to handle possible NULL values.
|
||||||
*/
|
*/
|
||||||
typedef list_hash_t (*element_hash_computer) (const void *el);
|
typedef list_hash_t(*element_hash_computer)(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a function for serializing an element.
|
* a function for serializing an element.
|
||||||
@ -133,7 +133,7 @@ extern "C" {
|
|||||||
* @param serialize_buffer reference to fill with the length of the buffer
|
* @param serialize_buffer reference to fill with the length of the buffer
|
||||||
* @return reference to the buffer with the serialized data
|
* @return reference to the buffer with the serialized data
|
||||||
*/
|
*/
|
||||||
typedef void *(*element_serializer) (const void *restrict el, uint32_t *restrict serializ_len);
|
typedef void *(*element_serializer)(const void *restrict el, uint32_t *restrict serializ_len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a function for un-serializing an element.
|
* a function for un-serializing an element.
|
||||||
@ -150,7 +150,7 @@ extern "C" {
|
|||||||
* @param data_len reference to the location where to store the length of the data in the buffer returned
|
* @param data_len reference to the location where to store the length of the data in the buffer returned
|
||||||
* @return reference to a buffer with the original, unserialized representation of the element
|
* @return reference to a buffer with the original, unserialized representation of the element
|
||||||
*/
|
*/
|
||||||
typedef void *(*element_unserializer) (const void *restrict data, uint32_t *restrict data_len);
|
typedef void *(*element_unserializer)(const void *restrict data, uint32_t *restrict data_len);
|
||||||
|
|
||||||
/* [private-use] list entry -- olds actual user datum */
|
/* [private-use] list entry -- olds actual user datum */
|
||||||
struct list_entry_s {
|
struct list_entry_s {
|
||||||
@ -210,7 +210,7 @@ extern "C" {
|
|||||||
* @param l must point to a user-provided memory location
|
* @param l must point to a user-provided memory location
|
||||||
* @return 0 for success. -1 for failure
|
* @return 0 for success. -1 for failure
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_init(list_t *restrict l);
|
int list_init(list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* completely remove the list from memory.
|
* completely remove the list from memory.
|
||||||
@ -221,7 +221,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @param l list to destroy
|
* @param l list to destroy
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(void) list_destroy(list_t *restrict l);
|
void list_destroy(list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the comparator function for list elements.
|
* set the comparator function for list elements.
|
||||||
@ -235,7 +235,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see element_comparator()
|
* @see element_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_attributes_comparator(list_t *restrict l, element_comparator comparator_fun);
|
int list_attributes_comparator(list_t *restrict l, element_comparator comparator_fun);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set a seeker function for list elements.
|
* set a seeker function for list elements.
|
||||||
@ -249,7 +249,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see element_seeker()
|
* @see element_seeker()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_attributes_seeker(list_t *restrict l, element_seeker seeker_fun);
|
int list_attributes_seeker(list_t *restrict l, element_seeker seeker_fun);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* require to free element data when list entry is removed (default: don't free).
|
* require to free element data when list entry is removed (default: don't free).
|
||||||
@ -281,7 +281,7 @@ extern "C" {
|
|||||||
* @see list_meter_double()
|
* @see list_meter_double()
|
||||||
* @see list_meter_string()
|
* @see list_meter_string()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_attributes_copy(list_t *restrict l, element_meter metric_fun, int copy_data);
|
int list_attributes_copy(list_t *restrict l, element_meter metric_fun, int copy_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the element hash computing function for the list elements.
|
* set the element hash computing function for the list elements.
|
||||||
@ -301,7 +301,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see element_hash_computer()
|
* @see element_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_attributes_hash_computer(list_t *restrict l, element_hash_computer hash_computer_fun);
|
int list_attributes_hash_computer(list_t *restrict l, element_hash_computer hash_computer_fun);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the element serializer function for the list elements.
|
* set the element serializer function for the list elements.
|
||||||
@ -322,7 +322,7 @@ extern "C" {
|
|||||||
* @see list_dump_filedescriptor()
|
* @see list_dump_filedescriptor()
|
||||||
* @see list_restore_filedescriptor()
|
* @see list_restore_filedescriptor()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_attributes_serializer(list_t *restrict l, element_serializer serializer_fun);
|
int list_attributes_serializer(list_t *restrict l, element_serializer serializer_fun);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the element unserializer function for the list elements.
|
* set the element unserializer function for the list elements.
|
||||||
@ -344,7 +344,7 @@ extern "C" {
|
|||||||
* @see list_dump_filedescriptor()
|
* @see list_dump_filedescriptor()
|
||||||
* @see list_restore_filedescriptor()
|
* @see list_restore_filedescriptor()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_attributes_unserializer(list_t *restrict l, element_unserializer unserializer_fun);
|
int list_attributes_unserializer(list_t *restrict l, element_unserializer unserializer_fun);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* append data at the end of the list.
|
* append data at the end of the list.
|
||||||
@ -356,7 +356,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @return 1 for success. < 0 for failure
|
* @return 1 for success. < 0 for failure
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_append(list_t *restrict l, const void *data);
|
int list_append(list_t *restrict l, const void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* insert data in the head of the list.
|
* insert data in the head of the list.
|
||||||
@ -368,7 +368,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @return 1 for success. < 0 for failure
|
* @return 1 for success. < 0 for failure
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_prepend(list_t *restrict l, const void *restrict data);
|
int list_prepend(list_t *restrict l, const void *restrict data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extract the element in the top of the list.
|
* extract the element in the top of the list.
|
||||||
@ -378,7 +378,7 @@ extern "C" {
|
|||||||
* @param l list to operate
|
* @param l list to operate
|
||||||
* @return reference to user datum, or NULL on errors
|
* @return reference to user datum, or NULL on errors
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(void *) list_fetch(list_t *restrict l);
|
void *list_fetch(list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve an element at a given position.
|
* retrieve an element at a given position.
|
||||||
@ -387,7 +387,7 @@ extern "C" {
|
|||||||
* @param pos [0,size-1] position index of the element wanted
|
* @param pos [0,size-1] position index of the element wanted
|
||||||
* @return reference to user datum, or NULL on errors
|
* @return reference to user datum, or NULL on errors
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(void *) list_get_at(const list_t *restrict l, unsigned int pos);
|
void *list_get_at(const list_t *restrict l, unsigned int pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the maximum element of the list.
|
* return the maximum element of the list.
|
||||||
@ -401,7 +401,7 @@ extern "C" {
|
|||||||
* @param l list to operate
|
* @param l list to operate
|
||||||
* @return the reference to the element, or NULL
|
* @return the reference to the element, or NULL
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(void *) list_get_max(const list_t *restrict l);
|
void *list_get_max(const list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the minimum element of the list.
|
* return the minimum element of the list.
|
||||||
@ -415,7 +415,7 @@ extern "C" {
|
|||||||
* @param l list to operate
|
* @param l list to operate
|
||||||
* @return the reference to the element, or NULL
|
* @return the reference to the element, or NULL
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(void *) list_get_min(const list_t *restrict l);
|
void *list_get_min(const list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve and remove from list an element at a given position.
|
* retrieve and remove from list an element at a given position.
|
||||||
@ -424,7 +424,7 @@ extern "C" {
|
|||||||
* @param pos [0,size-1] position index of the element wanted
|
* @param pos [0,size-1] position index of the element wanted
|
||||||
* @return reference to user datum, or NULL on errors
|
* @return reference to user datum, or NULL on errors
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(void *) list_extract_at(list_t *restrict l, unsigned int pos);
|
void *list_extract_at(list_t *restrict l, unsigned int pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* insert an element at a given position.
|
* insert an element at a given position.
|
||||||
@ -434,7 +434,7 @@ extern "C" {
|
|||||||
* @param pos [0,size-1] position index to insert the element at
|
* @param pos [0,size-1] position index to insert the element at
|
||||||
* @return positive value on success. Negative on failure
|
* @return positive value on success. Negative on failure
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
|
int list_insert_at(list_t *restrict l, const void *data, unsigned int pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* expunge the first found given element from the list.
|
* expunge the first found given element from the list.
|
||||||
@ -451,7 +451,7 @@ extern "C" {
|
|||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
* @see list_delete_at()
|
* @see list_delete_at()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_delete(list_t *restrict l, const void *data);
|
int list_delete(list_t *restrict l, const void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* expunge an element at a given position from the list.
|
* expunge an element at a given position from the list.
|
||||||
@ -460,7 +460,7 @@ extern "C" {
|
|||||||
* @param pos [0,size-1] position index of the element to be deleted
|
* @param pos [0,size-1] position index of the element to be deleted
|
||||||
* @return 0 on success. Negative value on failure
|
* @return 0 on success. Negative value on failure
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_delete_at(list_t *restrict l, unsigned int pos);
|
int list_delete_at(list_t *restrict l, unsigned int pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* expunge an array of elements from the list, given their position range.
|
* expunge an array of elements from the list, given their position range.
|
||||||
@ -470,7 +470,7 @@ extern "C" {
|
|||||||
* @param posend [posstart,size-1] position of the last element to be deleted
|
* @param posend [posstart,size-1] position of the last element to be deleted
|
||||||
* @return the number of elements successfully removed on success, <0 on error
|
* @return the number of elements successfully removed on success, <0 on error
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int posend);
|
int list_delete_range(list_t *restrict l, unsigned int posstart, unsigned int posend);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clear all the elements off of the list.
|
* clear all the elements off of the list.
|
||||||
@ -483,7 +483,7 @@ extern "C" {
|
|||||||
* @param l list to operate
|
* @param l list to operate
|
||||||
* @return the number of elements removed on success, <0 on error
|
* @return the number of elements removed on success, <0 on error
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_clear(list_t *restrict l);
|
int list_clear(list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inspect the number of elements in the list.
|
* inspect the number of elements in the list.
|
||||||
@ -491,7 +491,7 @@ extern "C" {
|
|||||||
* @param l list to operate
|
* @param l list to operate
|
||||||
* @return number of elements currently held by the list
|
* @return number of elements currently held by the list
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(unsigned int) list_size(const list_t *restrict l);
|
unsigned int list_size(const list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inspect whether the list is empty.
|
* inspect whether the list is empty.
|
||||||
@ -501,7 +501,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see list_size()
|
* @see list_size()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_empty(const list_t *restrict l);
|
int list_empty(const list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find the position of an element in a list.
|
* find the position of an element in a list.
|
||||||
@ -520,7 +520,7 @@ extern "C" {
|
|||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
* @see list_get_at()
|
* @see list_get_at()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_locate(const list_t *restrict l, const void *data);
|
int list_locate(const list_t *restrict l, const void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns an element given an indicator.
|
* returns an element given an indicator.
|
||||||
@ -535,7 +535,7 @@ extern "C" {
|
|||||||
* @param indicator indicator data to pass to the seeker along with elements
|
* @param indicator indicator data to pass to the seeker along with elements
|
||||||
* @return reference to the element accepted by the seeker, or NULL if none found
|
* @return reference to the element accepted by the seeker, or NULL if none found
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(void *) list_seek(list_t *restrict l, const void *indicator);
|
void *list_seek(list_t *restrict l, const void *indicator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inspect whether some data is member of the list.
|
* inspect whether some data is member of the list.
|
||||||
@ -556,7 +556,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_contains(const list_t *restrict l, const void *data);
|
int list_contains(const list_t *restrict l, const void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* concatenate two lists
|
* concatenate two lists
|
||||||
@ -575,7 +575,7 @@ extern "C" {
|
|||||||
* @param dest reference to the destination list
|
* @param dest reference to the destination list
|
||||||
* @return 0 for success, -1 for errors
|
* @return 0 for success, -1 for errors
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_concat(const list_t *l1, const list_t *l2, list_t *restrict dest);
|
int list_concat(const list_t *l1, const list_t *l2, list_t *restrict dest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sort list elements.
|
* sort list elements.
|
||||||
@ -592,7 +592,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_sort(list_t *restrict l, int versus);
|
int list_sort(list_t *restrict l, int versus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* start an iteration session.
|
* start an iteration session.
|
||||||
@ -604,7 +604,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see list_iterator_stop()
|
* @see list_iterator_stop()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_iterator_start(list_t *restrict l);
|
int list_iterator_start(list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the next element in the iteration session.
|
* return the next element in the iteration session.
|
||||||
@ -612,7 +612,7 @@ extern "C" {
|
|||||||
* @param l list to operate
|
* @param l list to operate
|
||||||
* @return element datum, or NULL on errors
|
* @return element datum, or NULL on errors
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(void *) list_iterator_next(list_t *restrict l);
|
void *list_iterator_next(list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inspect whether more elements are available in the iteration session.
|
* inspect whether more elements are available in the iteration session.
|
||||||
@ -620,7 +620,7 @@ extern "C" {
|
|||||||
* @param l list to operate
|
* @param l list to operate
|
||||||
* @return 0 iff no more elements are available.
|
* @return 0 iff no more elements are available.
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_iterator_hasnext(const list_t *restrict l);
|
int list_iterator_hasnext(const list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* end an iteration session.
|
* end an iteration session.
|
||||||
@ -628,7 +628,7 @@ extern "C" {
|
|||||||
* @param l list to operate
|
* @param l list to operate
|
||||||
* @return 0 iff the iteration session cannot be stopped
|
* @return 0 iff the iteration session cannot be stopped
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_iterator_stop(list_t *restrict l);
|
int list_iterator_stop(list_t *restrict l);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the hash of the current status of the list.
|
* return the hash of the current status of the list.
|
||||||
@ -638,7 +638,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @return 0 for success; <0 for failure
|
* @return 0 for success; <0 for failure
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_hash(const list_t *restrict l, list_hash_t *restrict hash);
|
int list_hash(const list_t *restrict l, list_hash_t *restrict hash);
|
||||||
|
|
||||||
#ifndef SIMCLIST_NO_DUMPRESTORE
|
#ifndef SIMCLIST_NO_DUMPRESTORE
|
||||||
/**
|
/**
|
||||||
@ -656,7 +656,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see list_dump_filedescriptor()
|
* @see list_dump_filedescriptor()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_dump_getinfo_filedescriptor(int fd, list_dump_info_t *restrict info);
|
int list_dump_getinfo_filedescriptor(int fd, list_dump_info_t *restrict info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get meta informations on a list dump on file.
|
* get meta informations on a list dump on file.
|
||||||
@ -671,7 +671,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* @see list_dump_filedescriptor()
|
* @see list_dump_filedescriptor()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_dump_getinfo_file(const char *restrict filename, list_dump_info_t *restrict info);
|
int list_dump_getinfo_file(const char *restrict filename, list_dump_info_t *restrict info);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dump the list into an open, writable file descriptor.
|
* dump the list into an open, writable file descriptor.
|
||||||
@ -707,7 +707,7 @@ extern "C" {
|
|||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
* @see list_attributes_serializer()
|
* @see list_attributes_serializer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict len);
|
int list_dump_filedescriptor(const list_t *restrict l, int fd, size_t *restrict len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dump the list to a file name.
|
* dump the list to a file name.
|
||||||
@ -730,7 +730,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* This function stores a representation of the list
|
* This function stores a representation of the list
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_dump_file(const list_t *restrict l, const char *restrict filename, size_t *restrict len);
|
int list_dump_file(const list_t *restrict l, const char *restrict filename, size_t *restrict len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restore the list from an open, readable file descriptor to memory.
|
* restore the list from an open, readable file descriptor to memory.
|
||||||
@ -750,7 +750,7 @@ extern "C" {
|
|||||||
* @param len location to store the length of the dump read (bytes), or NULL
|
* @param len location to store the length of the dump read (bytes), or NULL
|
||||||
* @return 0 if successful; -1 otherwise
|
* @return 0 if successful; -1 otherwise
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len);
|
int list_restore_filedescriptor(list_t *restrict l, int fd, size_t *restrict len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restore the list from a file name.
|
* restore the list from a file name.
|
||||||
@ -768,7 +768,7 @@ extern "C" {
|
|||||||
* @param len location to store the length of the dump read (bytes), or NULL
|
* @param len location to store the length of the dump read (bytes), or NULL
|
||||||
* @return 0 if successful; -1 otherwise
|
* @return 0 if successful; -1 otherwise
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_restore_file(list_t *restrict l, const char *restrict filename, size_t *len);
|
int list_restore_file(list_t *restrict l, const char *restrict filename, size_t *len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ready-made comparators, meters and hash computers */
|
/* ready-made comparators, meters and hash computers */
|
||||||
@ -777,206 +777,208 @@ extern "C" {
|
|||||||
* ready-made comparator for int8_t elements.
|
* ready-made comparator for int8_t elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_int8_t (const void *a, const void *b);
|
int list_comparator_int8_t(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for int16_t elements.
|
* ready-made comparator for int16_t elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_int16_t (const void *a, const void *b);
|
int list_comparator_int16_t(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for int32_t elements.
|
* ready-made comparator for int32_t elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_int32_t (const void *a, const void *b);
|
int list_comparator_int32_t(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for int64_t elements.
|
* ready-made comparator for int64_t elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_int64_t (const void *a, const void *b);
|
int list_comparator_int64_t(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for uint8_t elements.
|
* ready-made comparator for uint8_t elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_uint8_t (const void *a, const void *b);
|
int list_comparator_uint8_t(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for uint16_t elements.
|
* ready-made comparator for uint16_t elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_uint16_t (const void *a, const void *b);
|
int list_comparator_uint16_t(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for uint32_t elements.
|
* ready-made comparator for uint32_t elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_uint32_t (const void *a, const void *b);
|
int list_comparator_uint32_t(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for uint64_t elements.
|
* ready-made comparator for uint64_t elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_uint64_t (const void *a, const void *b);
|
int list_comparator_uint64_t(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for float elements.
|
* ready-made comparator for float elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_float(const void *a, const void *b);
|
int list_comparator_float(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for double elements.
|
* ready-made comparator for double elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_double(const void *a, const void *b);
|
int list_comparator_double(const void *a, const void *b);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made comparator for string elements.
|
* ready-made comparator for string elements.
|
||||||
* @see list_attributes_comparator()
|
* @see list_attributes_comparator()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(int) list_comparator_string(const void *a, const void *b);
|
int list_comparator_string(const void *a, const void *b);
|
||||||
|
|
||||||
/* metric functions */
|
/* metric functions */
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for int8_t elements.
|
* ready-made metric function for int8_t elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_int8_t (const void *el);
|
size_t list_meter_int8_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for int16_t elements.
|
* ready-made metric function for int16_t elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_int16_t (const void *el);
|
size_t list_meter_int16_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for int32_t elements.
|
* ready-made metric function for int32_t elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_int32_t (const void *el);
|
size_t list_meter_int32_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for int64_t elements.
|
* ready-made metric function for int64_t elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_int64_t (const void *el);
|
size_t list_meter_int64_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for uint8_t elements.
|
* ready-made metric function for uint8_t elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_uint8_t (const void *el);
|
size_t list_meter_uint8_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for uint16_t elements.
|
* ready-made metric function for uint16_t elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_uint16_t (const void *el);
|
size_t list_meter_uint16_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for uint32_t elements.
|
* ready-made metric function for uint32_t elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_uint32_t (const void *el);
|
size_t list_meter_uint32_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for uint64_t elements.
|
* ready-made metric function for uint64_t elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_uint64_t (const void *el);
|
size_t list_meter_uint64_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for float elements.
|
* ready-made metric function for float elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_float(const void *el);
|
size_t list_meter_float(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for double elements.
|
* ready-made metric function for double elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_double(const void *el);
|
size_t list_meter_double(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made metric function for string elements.
|
* ready-made metric function for string elements.
|
||||||
* @see list_attributes_copy()
|
* @see list_attributes_copy()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(size_t) list_meter_string(const void *el);
|
size_t list_meter_string(const void *el);
|
||||||
|
|
||||||
/* hash functions */
|
/* hash functions */
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for int8_t elements.
|
* ready-made hash function for int8_t elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_int8_t(const void *el);
|
list_hash_t list_hashcomputer_int8_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for int16_t elements.
|
* ready-made hash function for int16_t elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_int16_t(const void *el);
|
list_hash_t list_hashcomputer_int16_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for int32_t elements.
|
* ready-made hash function for int32_t elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_int32_t(const void *el);
|
list_hash_t list_hashcomputer_int32_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for int64_t elements.
|
* ready-made hash function for int64_t elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_int64_t(const void *el);
|
list_hash_t list_hashcomputer_int64_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for uint8_t elements.
|
* ready-made hash function for uint8_t elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_uint8_t(const void *el);
|
list_hash_t list_hashcomputer_uint8_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for uint16_t elements.
|
* ready-made hash function for uint16_t elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_uint16_t(const void *el);
|
list_hash_t list_hashcomputer_uint16_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for uint32_t elements.
|
* ready-made hash function for uint32_t elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_uint32_t(const void *el);
|
list_hash_t list_hashcomputer_uint32_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for uint64_t elements.
|
* ready-made hash function for uint64_t elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_uint64_t(const void *el);
|
list_hash_t list_hashcomputer_uint64_t(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for float elements.
|
* ready-made hash function for float elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_float(const void *el);
|
list_hash_t list_hashcomputer_float(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for double elements.
|
* ready-made hash function for double elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_double(const void *el);
|
list_hash_t list_hashcomputer_double(const void *el);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ready-made hash function for string elements.
|
* ready-made hash function for string elements.
|
||||||
* @see list_attributes_hash_computer()
|
* @see list_attributes_hash_computer()
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(list_hash_t) list_hashcomputer_string(const void *el);
|
list_hash_t list_hashcomputer_string(const void *el);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* mode:c
|
* mode:c
|
||||||
|
@ -64,6 +64,9 @@ KS_DECLARE(ks_status_t) ks_global_set_cleanup(ks_pool_cleanup_fn_t fn, void *arg
|
|||||||
KS_DECLARE(ks_status_t) ks_init(void)
|
KS_DECLARE(ks_status_t) ks_init(void)
|
||||||
{
|
{
|
||||||
unsigned int pid = 0;
|
unsigned int pid = 0;
|
||||||
|
|
||||||
|
ks_time_init();
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
pid = _getpid();
|
pid = _getpid();
|
||||||
#else
|
#else
|
||||||
|
@ -383,7 +383,8 @@ KS_DECLARE(ks_status_t) ks_cond_wait(ks_cond_t *cond)
|
|||||||
KS_DECLARE(ks_status_t) ks_cond_timedwait(ks_cond_t *cond, ks_time_t ms)
|
KS_DECLARE(ks_status_t) ks_cond_timedwait(ks_cond_t *cond, ks_time_t ms)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if(!SleepConditionVariableCS(&cond->cond, &cond->mutex->mutex, (DWORD)ms)) {
|
BOOL res = SleepConditionVariableCS(&cond->cond, &cond->mutex->mutex, (DWORD)ms);
|
||||||
|
if (!res) {
|
||||||
if (GetLastError() == ERROR_TIMEOUT) {
|
if (GetLastError() == ERROR_TIMEOUT) {
|
||||||
return KS_STATUS_TIMEOUT;
|
return KS_STATUS_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
|
@ -67,6 +67,10 @@ static void ks_q_cleanup(ks_pool_t *mpool, void *ptr, void *arg, int type, ks_po
|
|||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case KS_MPCL_ANNOUNCE:
|
case KS_MPCL_ANNOUNCE:
|
||||||
|
if (q->active) {
|
||||||
|
ks_q_flush(q);
|
||||||
|
ks_q_term(q);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case KS_MPCL_TEARDOWN:
|
case KS_MPCL_TEARDOWN:
|
||||||
np = q->head;
|
np = q->head;
|
||||||
@ -227,6 +231,7 @@ static ks_status_t do_push(ks_q_t *q, void *ptr)
|
|||||||
ks_qnode_t *node;
|
ks_qnode_t *node;
|
||||||
|
|
||||||
ks_mutex_lock(q->list_mutex);
|
ks_mutex_lock(q->list_mutex);
|
||||||
|
|
||||||
if (!q->active) {
|
if (!q->active) {
|
||||||
ks_mutex_unlock(q->list_mutex);
|
ks_mutex_unlock(q->list_mutex);
|
||||||
return KS_STATUS_INACTIVE;
|
return KS_STATUS_INACTIVE;
|
||||||
|
@ -129,13 +129,20 @@ static void *worker_thread(ks_thread_t *thread, void *data)
|
|||||||
ks_status_t status;
|
ks_status_t status;
|
||||||
|
|
||||||
status = ks_q_pop_timeout(tp->q, &pop, 1000);
|
status = ks_q_pop_timeout(tp->q, &pop, 1000);
|
||||||
|
if (status == KS_STATUS_BREAK) {
|
||||||
|
if (tp->state != TP_STATE_RUNNING) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ks_log(KS_LOG_DEBUG, "WORKER %d idle_sec %d running %d dying %d total %d max %d\n",
|
ks_log(KS_LOG_DEBUG, "WORKER %d idle_sec %d running %d dying %d total %d max %d\n",
|
||||||
my_id, idle_sec, tp->running_thread_count, tp->dying_thread_count, tp->thread_count, tp->max);
|
my_id, idle_sec, tp->running_thread_count, tp->dying_thread_count, tp->thread_count, tp->max);
|
||||||
*/
|
*/
|
||||||
check_queue(tp, KS_FALSE);
|
check_queue(tp, KS_FALSE);
|
||||||
|
|
||||||
if (status == KS_STATUS_TIMEOUT || status == KS_STATUS_BREAK) {
|
if (status == KS_STATUS_TIMEOUT) { // || status == KS_STATUS_BREAK) {
|
||||||
idle_sec++;
|
idle_sec++;
|
||||||
|
|
||||||
if (idle_sec >= tp->idle_sec) {
|
if (idle_sec >= tp->idle_sec) {
|
||||||
@ -148,7 +155,6 @@ static void *worker_thread(ks_thread_t *thread, void *data)
|
|||||||
ks_mutex_unlock(tp->mutex);
|
ks_mutex_unlock(tp->mutex);
|
||||||
|
|
||||||
if (die) {
|
if (die) {
|
||||||
ks_log(KS_LOG_DEBUG, "WORKER %d IDLE TIMEOUT\n", my_id);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,8 +162,8 @@ static void *worker_thread(ks_thread_t *thread, void *data)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((status != KS_STATUS_SUCCESS && status != KS_STATUS_BREAK) || !pop) {
|
if ((status != KS_STATUS_SUCCESS && status != KS_STATUS_BREAK)) {
|
||||||
ks_log(KS_LOG_DEBUG, "WORKER %d POP FAIL %d %p\n", my_id, status, (void *)pop);
|
ks_log(KS_LOG_ERROR, "WORKER %d POP FAIL %d %p\n", my_id, status, (void *)pop);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ static DWORD win32_last_get_time_tick = 0;
|
|||||||
|
|
||||||
static uint8_t win32_use_qpc = 0;
|
static uint8_t win32_use_qpc = 0;
|
||||||
static uint64_t win32_qpc_freq = 0;
|
static uint64_t win32_qpc_freq = 0;
|
||||||
static int timer_init;
|
|
||||||
static inline void win32_init_timers(void)
|
static inline void win32_init_timers(void)
|
||||||
{
|
{
|
||||||
OSVERSIONINFOEX version_info; /* Used to fetch current OS version from Windows */
|
OSVERSIONINFOEX version_info; /* Used to fetch current OS version from Windows */
|
||||||
@ -86,18 +86,17 @@ static inline void win32_init_timers(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(&timer_section);
|
LeaveCriticalSection(&timer_section);
|
||||||
|
}
|
||||||
|
|
||||||
timer_init = 1;
|
KS_DECLARE(void) ks_time_init(void)
|
||||||
|
{
|
||||||
|
win32_init_timers();
|
||||||
}
|
}
|
||||||
|
|
||||||
KS_DECLARE(ks_time_t) ks_time_now(void)
|
KS_DECLARE(ks_time_t) ks_time_now(void)
|
||||||
{
|
{
|
||||||
ks_time_t now;
|
ks_time_t now;
|
||||||
|
|
||||||
if (!timer_init) {
|
|
||||||
win32_init_timers();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (win32_use_qpc) {
|
if (win32_use_qpc) {
|
||||||
/* Use QueryPerformanceCounter */
|
/* Use QueryPerformanceCounter */
|
||||||
uint64_t count = 0;
|
uint64_t count = 0;
|
||||||
@ -133,10 +132,6 @@ KS_DECLARE(ks_time_t) ks_time_now_sec(void)
|
|||||||
{
|
{
|
||||||
ks_time_t now;
|
ks_time_t now;
|
||||||
|
|
||||||
if (!timer_init) {
|
|
||||||
win32_init_timers();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (win32_use_qpc) {
|
if (win32_use_qpc) {
|
||||||
/* Use QueryPerformanceCounter */
|
/* Use QueryPerformanceCounter */
|
||||||
uint64_t count = 0;
|
uint64_t count = 0;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@ static void *test1_thread(ks_thread_t *thread, void *data)
|
|||||||
{
|
{
|
||||||
struct x *mydata = (struct x *) data;
|
struct x *mydata = (struct x *) data;
|
||||||
|
|
||||||
ks_log(KS_LOG_DEBUG, "Thread %d\n", mydata->i);
|
//ks_log(KS_LOG_DEBUG, "Thread %d\n", mydata->i);
|
||||||
ks_sleep(100000);
|
ks_sleep(100000);
|
||||||
ks_pool_free(mydata->pool, &mydata);
|
ks_pool_free(mydata->pool, &mydata);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -37,6 +37,7 @@ static int test1()
|
|||||||
struct x *data = ks_pool_alloc(pool, sizeof(*data));
|
struct x *data = ks_pool_alloc(pool, sizeof(*data));
|
||||||
data->i = i;
|
data->i = i;
|
||||||
data->pool = pool;
|
data->pool = pool;
|
||||||
|
ks_sleep(1);
|
||||||
ks_thread_pool_add_job(tp, test1_thread, data);
|
ks_thread_pool_add_job(tp, test1_thread, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user