本文整理汇总了C++中recursive_mutex类的典型用法代码示例。如果您正苦于以下问题:C++ recursive_mutex类的具体用法?C++ recursive_mutex怎么用?C++ recursive_mutex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了recursive_mutex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: endRouters
vector<uint32_t>::const_iterator endRouters()
{
lock.unlock();
auto it = routers.end();
lock.unlock();
return it;
}
示例2: addFriend
void addFriend(SceNetAdhocctlConnectPacketS2C * packet) {
// Allocate Structure
SceNetAdhocctlPeerInfo * peer = (SceNetAdhocctlPeerInfo *)malloc(sizeof(SceNetAdhocctlPeerInfo));
// Allocated Structure
if(peer != NULL) {
// Clear Memory
memset(peer, 0, sizeof(SceNetAdhocctlPeerInfo));
// Link to existing Peers
peer->next = friends;
// Save Nickname
peer->nickname = packet->name;
// Save MAC Address
peer->mac_addr = packet->mac;
// Save IP Address
peer->ip_addr = packet->ip;
// Multithreading Lock
peerlock.lock();
// Link into Peerlist
friends = peer;
// Multithreading Unlock
peerlock.unlock();
}
}
示例3: producerSatisfiedAuthRequest
void producerSatisfiedAuthRequest( const Name& producer_name,
const Name& request_name,
const NdnParameterSet& credentials )
{
if( logging_enabled )
{
lock.lock();
log_file << "Producer:SatisfiedAuth" << endl
<< "{" << endl
<< " time = " << time::system_clock::now() << endl
<< " producer = " << producer_name.toUri() << endl
<< " request = " << request_name.toUri() << endl
<< " username = " <<
( ( credentials.hasParameter( "username" ) )
? credentials.getParameter( "username" )
: "none" )
<< endl
<< " password = " <<
( ( credentials.hasParameter( "password" ) )
? credentials.getParameter( "password" )
: "none" )
<< endl
<< "}" << endl;
lock.unlock();
}
}
示例4: routerStartedCount
size_t routerStartedCount()
{
lock.lock();
auto count = routers_started.size();
lock.unlock();
return count;
}
示例5: beginRouters
vector<uint32_t>::const_iterator beginRouters()
{
lock.lock();
auto it = routers.begin();
lock.unlock();
return it;
}
示例6: endProducers
vector<uint32_t>::const_iterator endProducers()
{
lock.lock();
auto it = producers.end();
lock.unlock();
return it;
}
示例7: producerStartedCount
size_t producerStartedCount()
{
lock.lock();
auto count = producers_started.size();
lock.unlock();
return count;
}
示例8: consumerStartedCount
size_t consumerStartedCount()
{
lock.lock();
auto count = consumers_started.size();
lock.unlock();
return count;
}
示例9: nodeCount
size_t nodeCount()
{
lock.lock();
auto count = routers.size();
lock.unlock();
return count;
}
示例10: consumerCount
size_t consumerCount()
{
lock.lock();
auto count = consumers.size();
lock.unlock();
return count;
}
示例11: producerCount
size_t producerCount()
{
lock.lock();
auto count = producers.size();
lock.unlock();
return count;
}
示例12: deleteFriendByIP
void deleteFriendByIP(uint32_t ip) {
// Previous Peer Reference
SceNetAdhocctlPeerInfo * prev = NULL;
// Peer Pointer
SceNetAdhocctlPeerInfo * peer = friends;
// Iterate Peers
for(; peer != NULL; peer = peer->next) {
// Found Peer
if(peer->ip_addr == ip) {
// Multithreading Lock
peerlock.lock();
// Unlink Left (Beginning)
if(prev == NULL)friends = peer->next;
// Unlink Left (Other)
else prev->next = peer->next;
// Multithreading Unlock
peerlock.unlock();
// Free Memory
free(peer);
// Stop Search
break;
}
// Set Previous Reference
prev = peer;
}
}
示例13: endConsumers
vector<uint32_t>::const_iterator endConsumers()
{
lock.lock();
auto it = consumers.end();
lock.unlock();
return it;
}
示例14: removeProducer
void removeProducer( uint8_t producer_instance )
{
lock.lock();
auto it = find( producers.begin(), producers.end(), producer_instance );
if( it != producers.end() )
producers.erase( it );
lock.unlock();
}
示例15: workerFunction
static void workerFunction(){
mMutex.lock();
cout << "Operation Started" << endl;
workerFunction(); //this goes in a no ending loop if it works. Which means we can call recousively this function from the same thread
sleep(1);
cout << "Operation Terminated" << endl;
mMutex.unlock();
}