void vortex_mutex_lock ( VortexMutex mutex_def)

Locks the given mutex.

If the mutex is currently unlocked, it becomes locked and owned by the calling thread, and vortex_mutex_lock returns immediately. If the mutex is already locked by another thread, vortex_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 vortex_mutex_lock and vortex_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 vortex_mutex_lock cannot do a vortex_mutex_unlock until the owner thread do it.

Referenced by vortex_async_queue_foreach(), vortex_async_queue_items(), vortex_async_queue_length(), vortex_async_queue_lock(), vortex_async_queue_lookup(), vortex_async_queue_pop(), vortex_async_queue_priority_push(), vortex_async_queue_push(), vortex_async_queue_ref(), vortex_async_queue_ref_count(), vortex_async_queue_safe_unref(), vortex_async_queue_timedpop(), vortex_async_queue_unref(), vortex_async_queue_waiters(), vortex_channel_block_until_replies_are_sent(), vortex_channel_free(), vortex_channel_free_wait_reply(), vortex_channel_get_next_expected_reply_no(), vortex_channel_get_next_reply_no(), vortex_channel_get_outstanding_messages(), vortex_channel_is_empty_pending_message(), vortex_channel_is_ready(), vortex_channel_is_stalled(), vortex_channel_notify_close(), vortex_channel_ref2(), vortex_channel_ref_count(), vortex_channel_set_serialize(), vortex_channel_unref2(), vortex_channel_wait_reply_ref(), vortex_connection_add_channel_common(), vortex_connection_close(), vortex_connection_get_host_ip(), vortex_connection_get_next_channel(), vortex_connection_get_timeout(), vortex_connection_is_ok(), vortex_connection_is_profile_filtered(), vortex_connection_is_profile_supported(), vortex_connection_pop_channel_error(), vortex_connection_ref_internal(), vortex_connection_remove_handler(), vortex_connection_remove_on_close_full(), vortex_connection_set_channel_added_handler(), vortex_connection_set_channel_removed_handler(), vortex_connection_set_connection_actions(), vortex_connection_set_on_close(), vortex_connection_set_on_close_full2(), vortex_connection_set_profile_mask(), vortex_connection_unref(), vortex_ctx_free2(), vortex_ctx_install_cleanup(), vortex_ctx_ref2(), vortex_ctx_remove_cleanup(), vortex_ctx_unref2(), vortex_event_ref(), vortex_event_unref(), vortex_exit_ctx(), vortex_external_setup_ref(), vortex_external_setup_unref(), vortex_hash_clear(), vortex_hash_delete(), vortex_hash_destroy(), vortex_hash_exists(), vortex_hash_foreach(), vortex_hash_foreach2(), vortex_hash_foreach3(), vortex_hash_insert(), vortex_hash_lock_until_changed(), vortex_hash_lookup(), vortex_hash_lookup_and_clear(), vortex_hash_ref(), vortex_hash_remove(), vortex_hash_replace(), vortex_hash_replace_full(), vortex_hash_size(), vortex_http_setup_ref(), vortex_http_setup_unref(), vortex_listener_accept_connection(), vortex_listener_set_on_connection_accepted(), vortex_listener_set_port_sharing_handling(), vortex_listener_unlock(), vortex_listener_wait(), vortex_payload_feeder_free(), vortex_payload_feeder_ref(), vortex_profiles_acquire(), vortex_profiles_has_profiles(), vortex_profiles_register(), vortex_profiles_register_extended_start(), vortex_profiles_set_received_handler(), vortex_profiles_unregister(), vortex_queue_get_length(), vortex_queue_head_push(), vortex_queue_is_empty(), vortex_queue_peek(), vortex_queue_pop(), vortex_queue_push(), vortex_support_add_domain_search_path_ref(), vortex_support_check_search_path(), vortex_support_domain_find_data_file(), vortex_support_inet_ntoa(), vortex_thread_pool_add(), vortex_thread_pool_event_stats(), vortex_thread_pool_new_event(), vortex_thread_pool_remove(), vortex_thread_pool_remove_event(), vortex_thread_pool_stats(), vortex_websocket_setup_ref(), and vortex_websocket_setup_unref().