threadsafe_stack& operator=(threadsafe_stack const& other) noexcept { std::lock(this->m, other.m); std::lock_guard<TT> lockThis(this->m, std::adopt_lock); std::lock_guard<TT> lockOther(other.m, std::adopt_lock); data = other.data; }
void transactionsManager::addHandlerToTransaction(ptr<handlers::dataHandler> newHandler) { PUNTOEXE_FUNCTION_START(L"transactionsManager::addHandlerToTransaction"); // Retrieve the transactions manager and lock it /////////////////////////////////////////////////////////// transactionsManager* pManager = getTransactionsManager(); lockObject lockThis(pManager->m_lockObject.get()); // Find the thread's transactions stack /////////////////////////////////////////////////////////// std::thread::id threadId = std::this_thread::get_id(); tTransactionsMap::iterator findThread = pManager->m_transactions.find(threadId); if(findThread == pManager->m_transactions.end()) { return; } // Get the last transaction in the stack /////////////////////////////////////////////////////////// transaction* pLastTransaction = findThread->second.back(); // This throw if the stack is empty. It's OK pLastTransaction->addHandler(newHandler); PUNTOEXE_FUNCTION_END(); }
/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Add a transaction to the current thread's transactions // stack // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// bool transactionsManager::addTransaction(std::thread::id threadId, transaction* pTransaction) { PUNTOEXE_FUNCTION_START(L"transactionsManager::addTransaction"); // Retrieve the transactions manager and lock it /////////////////////////////////////////////////////////// transactionsManager* pManager = getTransactionsManager(); lockObject lockThis(pManager->m_lockObject.get()); // Push back the transaction and return true if this is // the first transaction in the stack /////////////////////////////////////////////////////////// pManager->m_transactions[threadId].push_back(pTransaction); return pManager->m_transactions[threadId].size() == 1; PUNTOEXE_FUNCTION_END(); }
/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Remove a transaction from the transactions stack // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// void transactionsManager::removeTransaction(std::thread::id threadId) { PUNTOEXE_FUNCTION_START(L"transactionsManager::removeTransaction"); // Retrieve the transactions manager and lock it /////////////////////////////////////////////////////////// transactionsManager* pManager = getTransactionsManager(); lockObject lockThis(pManager->m_lockObject.get()); // Find the thread's transactions stack /////////////////////////////////////////////////////////// tTransactionsMap::iterator findThread = pManager->m_transactions.find(threadId); if(findThread == pManager->m_transactions.end()) { PUNTOEXE_THROW(std::logic_error, "Transaction not found in the transactions stack"); } // Pop the last transaction in the stack /////////////////////////////////////////////////////////// transaction* pLastTransaction = findThread->second.back(); // This throw if the stack is empty. It's OK findThread->second.pop_back(); // If there are no parent transactions then return /////////////////////////////////////////////////////////// if(findThread->second.empty()) { pManager->m_transactions.erase(findThread); return; } // If there is a parent transaction then copy there the // dataHandlers from the removed transaction /////////////////////////////////////////////////////////// transaction* pParentTransaction = findThread->second.back(); pLastTransaction->copyHandlersTo(pParentTransaction); PUNTOEXE_FUNCTION_END(); }
ConnectionConfig& ConnectionConfig::operator=(const ConnectionConfig& other) { bool allowedCopyRect; unsigned char preferredEncoding; bool use8BitColor; int customCompressionLevel; int jpegCompressionLevel; bool viewOnly; bool isClipboardEnabled; bool useFullscreen; bool deiconifyOnRemoteBell; int scaleNumerator; int scaleDenominator; bool swapMouse; bool requestSharedSession; bool fitWindow; bool requestShapeUpdates; bool ignoreShapeUpdates; int localCursor; { AutoLock lockOther(&other.m_cs); allowedCopyRect = other.m_allowedCopyRect; preferredEncoding = other.m_preferredEncoding; use8BitColor = other.m_use8BitColor; customCompressionLevel = other.m_customCompressionLevel; jpegCompressionLevel = other.m_jpegCompressionLevel; viewOnly = other.m_viewOnly; isClipboardEnabled = other.m_isClipboardEnabled; useFullscreen = other.m_useFullscreen; deiconifyOnRemoteBell = other.m_deiconifyOnRemoteBell; scaleNumerator = other.m_scaleNumerator; scaleDenominator = other.m_scaleDenominator; swapMouse = other.m_swapMouse; requestSharedSession = other.m_requestSharedSession; fitWindow = other.m_fitWindow; requestShapeUpdates = other.m_requestShapeUpdates; ignoreShapeUpdates = other.m_ignoreShapeUpdates; localCursor = other.m_localCursor; } { AutoLock lockThis(&m_cs); m_allowedCopyRect = allowedCopyRect; m_preferredEncoding = preferredEncoding; m_use8BitColor = use8BitColor; m_customCompressionLevel = customCompressionLevel; m_jpegCompressionLevel = jpegCompressionLevel; m_viewOnly = viewOnly; m_isClipboardEnabled = isClipboardEnabled; m_useFullscreen = useFullscreen; m_deiconifyOnRemoteBell = deiconifyOnRemoteBell; m_scaleNumerator = scaleNumerator; m_scaleDenominator = scaleDenominator; m_swapMouse = swapMouse; m_requestSharedSession = requestSharedSession; m_fitWindow = fitWindow; m_requestShapeUpdates = requestShapeUpdates; m_ignoreShapeUpdates = ignoreShapeUpdates; m_localCursor = localCursor; } return *this; }