void dumpHosts() { RWKey::sp key = hostsLock.readLock(); map<string, HostInfo *>::iterator it; cout << "=== Begin Hosts ===" << endl; for (it = hosts.begin(); it != hosts.end(); it++) { cout << it->second->getHost() << endl; } cout << "==== End Hosts ====" << endl << endl; }
void reader(int id) { rwLock.readLock(); int i = rand() % buffer.size(); int data = buffer[i]; { lock_guard<mutex> lock(outputLock); cout << "reader " << id << " reads buffer[" << i << "] = " << data << endl; } rwLock.readUnLock(); }
string generate() { RWKey::sp key = infoLock.readLock(); char buf[32]; string msg; // First 31 bytes of cluster with null memset(buf, 0, 32); strncpy(buf, rc.getCluster().c_str(), 31); msg.assign(buf, 32); msg.append(OriCrypt_Encrypt(myInfo.getBlob(), rc.getKey())); return msg; }