Removed the 'cond_type' and 'sem_type' declarations

This commit is contained in:
fpagliughi 2026-01-10 15:50:17 -05:00
parent 6a71f1c216
commit b75b46b5fc
3 changed files with 7 additions and 25 deletions

View File

@ -129,7 +129,7 @@ void MQTTAsync_init_rand(void)
mutex_type mqttasync_mutex = NULL;
mutex_type socket_mutex = NULL;
mutex_type mqttcommand_mutex = NULL;
sem_type send_evt = NULL;
evt_type send_evt = NULL;
#if !defined(NO_HEAP_TRACKING)
extern mutex_type stack_mutex;
extern mutex_type heap_mutex;

View File

@ -262,16 +262,6 @@ evt_type Thread_create_evt(int *rc)
*rc = -1;
pthread_condattr_init(&attr);
#if 0
/* in theory, a monotonic clock should be able to be used. However on at least
* one system reported, even though setclock() reported success, it didn't work.
*/
if ((rc = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC)) == 0)
use_clock_monotonic = 1;
else
Log(LOG_ERROR, -1, "Error %d calling pthread_condattr_setclock(CLOCK_MONOTONIC)", rc);
#endif
evt = malloc(sizeof(evt_type_struct));
if (evt)
{
@ -295,7 +285,8 @@ int Thread_signal_evt(evt_type evt)
FUNC_ENTRY;
pthread_mutex_lock(&evt->mutex);
evt->val = 1;
rc = pthread_cond_signal(&evt->cond);
// TODO: Determine if this could be more efficient with pthread_cond_signal()
rc = pthread_cond_broadcast(&evt->cond);
pthread_mutex_unlock(&evt->mutex);
FUNC_EXIT_RC(rc);
@ -349,19 +340,19 @@ int Thread_destroy_evt(evt_type evt)
* @param rc return code: 0 for success, negative otherwise
* @return the new condition variable
*/
sem_type Thread_create_evt(int *rc)
evt_type Thread_create_evt(int *rc)
{
FUNC_ENTRY;
sem_type sem = CreateEvent(
evt_type evt = CreateEvent(
NULL, /* default security attributes */
FALSE, /* manual-reset event? */
FALSE, /* initial state is nonsignaled */
NULL /* object name */
);
if (rc)
*rc = (sem == NULL) ? GetLastError() : 0;
*rc = (evt == NULL) ? GetLastError() : 0;
FUNC_EXIT_RC(*rc);
return sem;
return evt;
}
/**

View File

@ -41,9 +41,7 @@
#define thread_id_type DWORD
#define thread_return_type DWORD
#define thread_fn LPTHREAD_START_ROUTINE
#define cond_type HANDLE
#define evt_type HANDLE
#define sem_type HANDLE
#undef ETIMEDOUT
#define ETIMEDOUT WSAETIMEDOUT
#else
@ -56,13 +54,6 @@
typedef thread_return_type (*thread_fn)(void*);
typedef struct { pthread_cond_t cond; pthread_mutex_t mutex; int val; } evt_type_struct;
typedef evt_type_struct *evt_type;
#if defined(OSX)
#include <dispatch/dispatch.h>
typedef dispatch_semaphore_t sem_type;
#else
#include <semaphore.h>
typedef sem_t *sem_type;
#endif
#endif
LIBMQTT_API void Paho_thread_start(thread_fn, void*);