vector<uint32_t>::const_iterator endRouters() { lock.unlock(); auto it = routers.end(); lock.unlock(); return it; }
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(); } }
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 = "******"username" ) ) ? credentials.getParameter( "username" ) : "none" ) << endl << " password = "******"password" ) ) ? credentials.getParameter( "password" ) : "none" ) << endl << "}" << endl; lock.unlock(); } }
size_t routerStartedCount() { lock.lock(); auto count = routers_started.size(); lock.unlock(); return count; }
vector<uint32_t>::const_iterator beginRouters() { lock.lock(); auto it = routers.begin(); lock.unlock(); return it; }
vector<uint32_t>::const_iterator endProducers() { lock.lock(); auto it = producers.end(); lock.unlock(); return it; }
size_t producerStartedCount() { lock.lock(); auto count = producers_started.size(); lock.unlock(); return count; }
size_t consumerStartedCount() { lock.lock(); auto count = consumers_started.size(); lock.unlock(); return count; }
size_t nodeCount() { lock.lock(); auto count = routers.size(); lock.unlock(); return count; }
size_t consumerCount() { lock.lock(); auto count = consumers.size(); lock.unlock(); return count; }
size_t producerCount() { lock.lock(); auto count = producers.size(); lock.unlock(); return count; }
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; } }
vector<uint32_t>::const_iterator endConsumers() { lock.lock(); auto it = consumers.end(); lock.unlock(); return it; }
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(); }
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(); }
void removeRouter( uint32_t router_instance ) { lock.lock(); auto it = find( routers.begin(), routers.end(), router_instance ); if( it != routers.end() ) routers.erase( it ); lock.unlock(); }
void removeConsumer( uint32_t consumer_instance ) { lock.lock(); auto it = find( consumers.begin(), consumers.end(), consumer_instance ); if( it != consumers.end() ) consumers.erase( it ); lock.unlock(); }
void routerStopped( uint32_t router_instance ) { lock.lock(); auto it = find( routers_started.begin(), routers_started.end(), router_instance ); if( it != routers_started.end() ) routers_started.erase( it ); lock.unlock(); }
void consumerStopped( uint32_t consumer_instance ) { lock.lock(); auto it = find( consumers_started.begin(), consumers_started.end(), consumer_instance ); if( it != consumers_started.end() ) consumers.erase( it ); lock.unlock(); }
NdnSigner* producerSigner( const Name& producer ) { lock.lock(); // make signer if not already available NdnSigner* ret = &producer_signers[producer]; lock.unlock(); return ret; }
void producerStopped( const Name& producer_instance ) { lock.lock(); auto it = find( producers_started.begin(), producers_started.end(), producer_instance ); if( it != producers_started.end() ) producers_started.erase( it ); lock.unlock(); }
void simulationOther( const string& msg ) { if( logging_enabled ) { lock.lock(); log_file << "Simulation:Other" << endl << "{" << endl << " time = " << time::system_clock::now() << endl << " msg = " << msg << endl << "}" << endl; lock.unlock(); } }
static void SetPauseAction(PauseAction act, bool waitComplete = true) { { lock_guard guard(pauseLock); actionLock.lock(); pauseAction = act; } actionComplete = false; pauseWait.notify_one(); while (waitComplete && !actionComplete) { actionWait.wait(actionLock); } actionLock.unlock(); }
void simulationStarted( bool enable_logging ) { logging_enabled = enable_logging; lock.lock(); log_file.open("scratch/SIMUATION.log"); log_file << "Simulation:Started" << endl << "{" << endl << " time = " << time::system_clock::now() << endl << " nodes = " << nodeCount() << endl << " producers = " << producerCount() << endl << " consumers = " << consumerCount() << endl << "}" << endl; lock.unlock(); }
void edgeCachingTag( uint32_t edge_instance, const Name& request_name, const string& filter_name ) { lock.lock(); log_file << "Edge:CachingTag" << endl << "{" << endl << " time = " << time::system_clock::now() << endl << " edge = " << edge_instance << endl << " request = " << request_name.toUri() << endl << " filter = " << filter_name << endl << "}" << endl; lock.unlock(); }
void edgeDroppingRequest( uint32_t edge_instance, const Name& request_name, const string& why ) { lock.lock(); log_file << "Edge:DroppingRequest" << endl << "{" << endl << " time = " << time::system_clock::now() << endl << " edge = " << edge_instance << endl << " request = " << request_name.toUri() << endl << " why = " << why << endl << "}" << endl; lock.unlock(); }
void consumerFollowedLink( uint32_t consumer_instance, const Name& request_name ) { if( logging_enabled ) { lock.lock(); log_file << "Consumer:FollowedLink" << endl << "{" << endl << " time = " << time::system_clock::now() << endl << " consumer = " << consumer_instance << endl << " link = " << request_name.toUri() << endl << "}" << endl; lock.unlock(); } }
void routerForwardedRequest( uint32_t router_instance, const Name& request_name ) { if( logging_enabled ) { lock.lock(); log_file << "Router:Forwarded" << endl << "{" << endl << " time = " << time::system_clock::now() << endl << " router = " << router_instance << endl << " request = " << request_name.toUri() << endl << "}" << endl; lock.unlock(); } }
void routerAuthDenied( uint32_t router_instance, const Name& request_name ) { if( logging_enabled ) { lock.lock(); log_file << "Router:ReceivedAuth" << endl << "{" << endl << " time = " << time::system_clock::now() << endl << " router = " << router_instance << endl << " request = " << request_name.toUri() << endl << "}" << endl; lock.unlock(); } }
void routerOther( uint32_t router_instance, const string& msg ) { if( logging_enabled ) { lock.lock(); log_file << "Router:Other" << endl << "{" << endl << " time = " << time::system_clock::now() << endl << " router = " << router_instance << endl << " msg = " << msg << endl << "}" << endl; lock.unlock(); } }