本文整理汇总了C++中SpinLock::Lock方法的典型用法代码示例。如果您正苦于以下问题:C++ SpinLock::Lock方法的具体用法?C++ SpinLock::Lock怎么用?C++ SpinLock::Lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpinLock
的用法示例。
在下文中一共展示了SpinLock::Lock方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
void NetworkManager::Run()
{
int threadId;
struct epoll_event events[100];
int numOfEvent, n;
g_networkThreadCountLock.Lock();
threadId = g_networkThreadCount++;
g_networkThreadCountLock.Unlock();
for(;;)
{
numOfEvent = epoll_wait(m_epollFdList[threadId], m_epollEvent2DList[threadId], 100, 2000);
//printf("NW thread %d\n", threadId);
if(numOfEvent < 0){
// critical error
fprintf(stderr, "[ERROR] epoll_wait() ERROR : %s\n", strerror(errno));
exit(1);
}
if(numOfEvent == 0)
{
continue;
}
//printf("NT %d activated\n", TC);
OnEvent(numOfEvent, threadId);
}
close(m_serverFd);
for(int i=0; i<NETWORK_THREAD_NUM; i++)
close(m_epollFdList[i]);
}
示例2: SingletonReleaseTextVector
void SingletonReleaseTextVector()
{
g_SpinLockTextVec.Lock();
if (g_pTextVec)
{
delete g_pTextVec;
g_pTextVec = 0;
}
g_SpinLockTextVec.Unlock();
}
示例3: SingletonReleaseHashTable
void SingletonReleaseHashTable()
{
g_SpinLockHashTable.Lock();
if (g_pObjHash)
{
delete g_pObjHash;
g_pObjHash = 0;
}
g_SpinLockHashTable.Unlock();
}
示例4: match
void duplicate_node::match(vector<duplicate_node*>& entrances,
search_duplicate_files_status* status,
SpinLock& lock)
{
duplicate_node* iter = this;
while (iter) {
bool first_matched = true;
duplicate_node* current_node = iter;
duplicate_node* last_node = iter;
euint current_symbol = iter->m_symbol;
while (current_node) {
{
SpinLock::Instance inst = lock.Lock();
if (status) {
status->m_current_status = search_duplicate_files_status::Matching;
status->m_processing_file = current_node->m_path.c_str();
}
}
if (current_node->m_symbol == current_symbol && current_node != last_node) {
last_node->m_next1 = current_node;
if (first_matched) {
entrances.push_back(last_node);
first_matched = false;
}
last_node->m_is_matched = true;
current_node->m_is_matched = true;
last_node = current_node;
}
current_node = current_node->m_next0;
}
iter = iter->m_next0;
while (iter && iter->m_is_matched) {
iter = iter->m_next0;
}
}
{
SpinLock::Instance inst = lock.Lock();
if (status) {
status->m_current_status = search_duplicate_files_status::Idling;
status->m_processing_file = nullptr;
}
}
}
示例5: SingletonGetHashTable
HashType * SingletonGetHashTable()
{
if (!g_pObjHash)
{
g_SpinLockHashTable.Lock();
if (!g_pObjHash)
g_pObjHash = new HashType;
g_SpinLockHashTable.Unlock();
}
return g_pObjHash;
}
示例6: SingletonGetTextVector
TextBufVecType * SingletonGetTextVector()
{
if (!g_pTextVec)
{
g_SpinLockTextVec.Lock();
if (!g_pTextVec)
g_pTextVec = new TextBufVecType;
g_SpinLockTextVec.Unlock();
}
return g_pTextVec;
}
示例7: prepare
euint64 duplicate_node::prepare(duplicate_node_cache* cache,
search_duplicate_files_status* status,
SpinLock& lock)
{
euint64 proced_size = 0;
duplicate_node* iter = this;
while (iter) {
iter->m_next1 = nullptr;
iter->m_symbol = 0;
iter->m_is_matched = false;
cache->open(iter);
{
SpinLock::Instance inst = lock.Lock();
if (status) {
status->m_current_status = search_duplicate_files_status::Reading;
status->m_processing_file = iter->m_path.c_str();
}
}
///fseek(iter->m_file.get(), iter->m_offset, SEEK_SET);
iter->m_file.Seek(iter->m_offset);
///fread(&iter->m_symbol, 1, sizeof(SYMBOL), iter->m_file.get());
iter->m_file.Read(&iter->m_symbol, sizeof(SYMBOL));
proced_size += sizeof(SYMBOL);
m_remainder -= sizeof(SYMBOL);
iter->m_offset += sizeof(SYMBOL);
iter = iter->m_next0;
}
{
{
SpinLock::Instance inst = lock.Lock();
if (status) {
status->m_current_status = search_duplicate_files_status::Idling;
status->m_processing_file = nullptr;
}
}
}
return proced_size;
}
示例8: while
void xhn::thread::assign_to_local_thread(thread_ptr& local_thread, thread_ptr& global_thread, SpinLock& lock)
{
{
xhn::SpinLock::Instance inst = lock.Lock();
local_thread = global_thread;
}
if (!local_thread) {
local_thread = VNEW xhn::thread;
while (!local_thread->is_running()) {}
{
xhn::SpinLock::Instance inst = lock.Lock();
if (!global_thread) {
global_thread = local_thread;
}
else {
local_thread = global_thread;
}
}
}
}