void myqtt_mutex_lock ( MyQttMutex mutex_def)

Locks the given mutex.

If the mutex is currently unlocked, it becomes locked and owned by the calling thread, and myqtt_mutex_lock returns immediately. If the mutex is already locked by another thread, myqtt_mutex_lock suspends the calling thread until the mutex is unlocked.

Parameters
mutex_defThe reference to the mutex to be locked. If the mutex reference is NULL no lock operation is performed.

NOTE: It is important to use the pair of calls to myqtt_mutex_lock and myqtt_mutex_unlock from the same thread. This is because under windows, the couple of functions WaitForSingleObject and ReleaseMutex are used to implement lock and unlocking. Under this context, a thread not owning a mutex (acquired via WaitForSingleObject) can't release it with ReleaseMutex. This has the case consequence that a thread that has not called to myqtt_mutex_lock cannot do a myqtt_mutex_unlock until the owner thread do it.

Referenced by myqtt_async_queue_foreach(), myqtt_async_queue_items(), myqtt_async_queue_length(), myqtt_async_queue_lock(), myqtt_async_queue_lookup(), myqtt_async_queue_pop(), myqtt_async_queue_priority_push(), myqtt_async_queue_push(), myqtt_async_queue_ref(), myqtt_async_queue_ref_count(), myqtt_async_queue_safe_unref(), myqtt_async_queue_timedpop(), myqtt_async_queue_unref(), myqtt_async_queue_waiters(), myqtt_conn_close(), myqtt_conn_get_host_ip(), myqtt_conn_get_next(), myqtt_conn_get_timeout(), myqtt_conn_is_ok(), myqtt_conn_ping(), myqtt_conn_ref_count(), myqtt_conn_remove_on_close(), myqtt_conn_set_on_close(), myqtt_conn_set_on_close_full2(), myqtt_conn_set_on_msg(), myqtt_conn_unref(), myqtt_ctx_free2(), myqtt_ctx_install_cleanup(), myqtt_ctx_ref2(), myqtt_ctx_ref_count(), myqtt_ctx_remove_cleanup(), myqtt_ctx_set_on_connect(), myqtt_ctx_set_on_header(), myqtt_ctx_set_on_msg(), myqtt_ctx_set_on_publish(), myqtt_ctx_set_on_release(), myqtt_ctx_set_on_store(), myqtt_ctx_set_on_subscribe(), myqtt_ctx_set_on_unsubscribe(), myqtt_ctx_unref2(), myqtt_exit_ctx(), myqtt_hash_clear(), myqtt_hash_delete(), myqtt_hash_destroy(), myqtt_hash_exists(), myqtt_hash_foreach(), myqtt_hash_foreach2(), myqtt_hash_foreach3(), myqtt_hash_insert(), myqtt_hash_lock_until_changed(), myqtt_hash_lookup(), myqtt_hash_lookup_and_clear(), myqtt_hash_ref(), myqtt_hash_remove(), myqtt_hash_replace(), myqtt_hash_replace_full(), myqtt_hash_size(), myqtt_listener_accept_connection(), myqtt_listener_set_on_connection_accepted(), myqtt_listener_set_port_sharing_handling(), myqtt_listener_unlock(), myqtt_listener_wait(), myqtt_msg_ref(), myqtt_msg_ref_count(), myqtt_msg_unref(), myqtt_storage_clear(), myqtt_storage_init(), myqtt_storage_queued_flush(), myqtt_storage_set_path(), myqtt_support_add_domain_search_path_ref(), myqtt_support_check_search_path(), myqtt_support_domain_find_data_file(), myqtt_support_inet_ntoa(), myqtt_thread_pool_add(), myqtt_thread_pool_event_stats(), myqtt_thread_pool_new_event(), myqtt_thread_pool_remove(), myqtt_thread_pool_remove_event(), myqtt_thread_pool_stats(), myqtt_tls_init(), myqtt_web_socket_get_ctx(), myqttd_conn_mgr_conn_list(), myqttd_conn_mgr_count(), myqttd_conn_mgr_find_by_id(), myqttd_ctx_add_on_publish(), myqttd_ctx_get_data(), myqttd_ctx_set_data(), myqttd_ctx_set_data_full(), myqttd_module_exists_by_name(), myqttd_module_notify(), myqttd_module_register(), myqttd_module_skip_unmap(), myqttd_module_unload(), myqttd_module_unregister(), myqttd_reload_config(), and myqttd_signal_received().