◐ Shell
clean mode source ↗

std::recursive_mutex::unlock - cppreference.com

Da cppreference.com.

Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.

La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui.

Click here for the English version of this page

<metanoindex/>

<tbody> </tbody>

void unlock();

(dal C++11)

Sblocca il mutex.

Original:

Unlocks the mutex.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Parametri

(Nessuno)

Original:

(none)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valore di ritorno

(Nessuno)

Original:

(none)

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Eccezioni

Esempio

Questo esempio mostra blocco, try_lock e sbloccare in azione

Original:

This example shows lock, try_lock and unlock in action

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <mutex>
	
int main()
{
    std::mutex test;
    if (test.try_lock()==true)
        std::cout << "lock acquired" << std::endl;
    else
        std::cout << "lock not acquired" << std::endl;
    test.unlock();	//now unlock the mutex
    test.lock();	//to lock it again
    if (test.try_lock())  //true can be left out
        std::cout << "lock acquired" << std::endl;
    else
        std::cout << "lock not acquired" << std::endl;
    test.lock(); //and now the finale (a block)
}

Output:

lock acquired
lock not acquired
(program hangs)

Vedi anche

blocca i blocchi mutex, se il mutex non è disponibile

Original:

locks the mutex, blocks if the mutex is not available

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(metodo pubblico) [modifica]

prova a bloccare il mutex, restituisce se il mutex non è disponibile

Original:

tries to lock the mutex, returns if the mutex is not available

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(metodo pubblico) [modifica]