当前位置: 首页>>代码示例>>C++>>正文


C++ ReleaseSRWLockShared函数代码示例

本文整理汇总了C++中ReleaseSRWLockShared函数的典型用法代码示例。如果您正苦于以下问题:C++ ReleaseSRWLockShared函数的具体用法?C++ ReleaseSRWLockShared怎么用?C++ ReleaseSRWLockShared使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ReleaseSRWLockShared函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ConsumeElement

BOOL ConsumeElement(int nThreadNum, int nRequestNum, HWND hWndLB) {

   // Get access to the queue to consume a new element
   AcquireSRWLockShared(&g_srwLock); 

   // Fall asleep until there is something to read.
   // Check if, while it was asleep, 
   // it was not decided that the thread should stop
   while (g_q.IsEmpty(nThreadNum) && !g_fShutdown) {
      // There was not a readable element
      AddText(hWndLB, TEXT("[%d] Nothing to process"), nThreadNum);
         
      // The queue is empty
      // --> Wait until a writer adds a new element to read
      //     and come back with the lock acquired in shared mode
      SleepConditionVariableSRW(&g_cvReadyToConsume, &g_srwLock, 
         INFINITE, CONDITION_VARIABLE_LOCKMODE_SHARED);
   }

   // When thread is exiting, the lock should be released for writer
   // and readers should be signaled through the condition variable
   if (g_fShutdown) {
      // Show that the current thread is exiting
      AddText(hWndLB, TEXT("[%d] bye bye"), nThreadNum);

      // Another writer thread might still be blocked on the lock
      // --> release it before exiting
      ReleaseSRWLockShared(&g_srwLock);

      // Notify other readers that it is time to exit
      // --> release readers
      WakeConditionVariable(&g_cvReadyToConsume);

      return(FALSE);
   }

   // Get the first new element
   CQueue::ELEMENT e;
   // Note: No need to test the return value since IsEmpty
   //       returned FALSE
   g_q.GetNewElement(nThreadNum, e);
      
   // No need to keep the lock any longer
   ReleaseSRWLockShared(&g_srwLock);

   // Show result of consuming the element
   AddText(hWndLB, TEXT("[%d] Processing %d:%d"), 
      nThreadNum, e.m_nThreadNum, e.m_nRequestNum);

   // A free slot is now available for writer threads to produce
   // --> wake up a writer thread
   WakeConditionVariable(&g_cvReadyToProduce);

   return(TRUE);
}
开发者ID:Jeanhwea,项目名称:WindowsViaCPP,代码行数:55,代码来源:Queue.cpp

示例2: winfs_read

static size_t winfs_read(struct file *f, void *buf, size_t count)
{
	AcquireSRWLockShared(&f->rw_lock);
	struct winfs_file *winfile = (struct winfs_file *) f;
	WaitForSingleObject(winfile->fp_mutex, INFINITE);
	size_t num_read = 0;
	while (count > 0)
	{
		DWORD count_dword = (DWORD)min(count, (size_t)UINT_MAX);
		DWORD num_read_dword;
		if (!ReadFile(winfile->handle, buf, count_dword, &num_read_dword, NULL))
		{
			if (GetLastError() == ERROR_HANDLE_EOF)
				break;
			log_warning("ReadFile() failed, error code: %d", GetLastError());
			num_read = -L_EIO;
			break;
		}
		if (num_read_dword == 0)
			break;
		num_read += num_read_dword;
		count -= num_read_dword;
	}
	ReleaseMutex(winfile->fp_mutex);
	ReleaseSRWLockShared(&f->rw_lock);
	return num_read;
}
开发者ID:Logan-lu,项目名称:flinux,代码行数:27,代码来源:winfs.c

示例3: winfs_statfs

static int winfs_statfs(struct file *f, struct statfs64 *buf)
{
	AcquireSRWLockShared(&f->rw_lock);
	struct winfs_file *winfile = (struct winfs_file *) f;
	FILE_FS_FULL_SIZE_INFORMATION info;
	IO_STATUS_BLOCK status_block;
	NTSTATUS status = NtQueryVolumeInformationFile(winfile->handle, &status_block, &info, sizeof(info), FileFsFullSizeInformation);
	int r = 0;
	if (!NT_SUCCESS(status))
	{
		log_warning("NtQueryVolumeInformationFile() failed, status: %x", status);
		r = -L_EIO;
		goto out;
	}
	buf->f_type = 0x5346544e; /* NTFS_SB_MAGIC */
	buf->f_bsize = info.SectorsPerAllocationUnit * info.BytesPerSector;
	buf->f_blocks = info.TotalAllocationUnits.QuadPart;
	buf->f_bfree = info.ActualAvailableAllocationUnits.QuadPart;
	buf->f_bavail = info.CallerAvailableAllocationUnits.QuadPart;
	buf->f_files = 0;
	buf->f_ffree = 0;
	buf->f_fsid.val[0] = 0;
	buf->f_fsid.val[1] = 0;
	buf->f_namelen = PATH_MAX;
	buf->f_frsize = 0;
	buf->f_flags = 0;
	buf->f_spare[0] = 0;
	buf->f_spare[1] = 0;
	buf->f_spare[2] = 0;
	buf->f_spare[3] = 0;
out:
	ReleaseSRWLockShared(&f->rw_lock);
	return r;
}
开发者ID:Logan-lu,项目名称:flinux,代码行数:34,代码来源:winfs.c

示例4: winfs_link

static int winfs_link(struct mount_point *mp, struct file *f, const char *newpath)
{
	AcquireSRWLockShared(&f->rw_lock);
	struct winfs_file *winfile = (struct winfs_file *) f;
	NTSTATUS status;
	int r = 0;
	char buf[sizeof(FILE_LINK_INFORMATION) + PATH_MAX * 2];
	FILE_LINK_INFORMATION *info = (FILE_LINK_INFORMATION *)buf;
	info->ReplaceIfExists = FALSE;
	info->RootDirectory = NULL;
	info->FileNameLength = 2 * filename_to_nt_pathname(mp, newpath, info->FileName, PATH_MAX);
	if (info->FileNameLength == 0)
	{
		r = -L_ENOENT;
		goto out;
	}
	IO_STATUS_BLOCK status_block;
	status = NtSetInformationFile(winfile->handle, &status_block, info, info->FileNameLength + sizeof(FILE_LINK_INFORMATION), FileLinkInformation);
	if (!NT_SUCCESS(status))
	{
		log_warning("NtSetInformationFile() failed, status: %x.", status);
		r = -L_ENOENT;
		goto out;
	}
out:
	ReleaseSRWLockShared(&f->rw_lock);
	return r;
}
开发者ID:Logan-lu,项目名称:flinux,代码行数:28,代码来源:winfs.c

示例5: ReleaseSRWLockShared

	void ui::sendmouse(char param, vector2d pos)
	{
		mouse.update(pos);

		uielement* front = 0;
		if (actionsenabled)
		{
			if (TryAcquireSRWLockShared(&uilock))
			{
				for (map<char, uielement*>::iterator elit = elements.begin(); elit != elements.end(); elit++)
				{
					if (util::colliding(pos, elit->second->bounds()) && elit->second->isactive())
					{
						if (front != 0)
							front->sendmouse(pos, -1);
						front = elit->second;
					}
				}
				ReleaseSRWLockShared(&uilock);
			}
		}

		if (front != 0)
		{
			mouse.setstate(front->sendmouse(pos, param));
		}
		else
		{
			mouse.setstate(param);

			if (mouse.getstate() == 1)
				mouse.setstate(0);
		}
	}
开发者ID:dreamsxin,项目名称:journey_client,代码行数:34,代码来源:ui.cpp

示例6: dassert

 void SimpleRWLock::unlock_shared() { 
     int& state = s.getRef();
     dassert( state == 1 );
     state--;
     shares--;
     ReleaseSRWLockShared(&_lock); 
 }
开发者ID:2812140729,项目名称:robomongo,代码行数:7,代码来源:rwlockimpl.cpp

示例7: nfs41_session_free_slot

void nfs41_session_free_slot(
    IN nfs41_session *session,
    IN uint32_t slotid)
{
    nfs41_slot_table *table = &session->table;

    AcquireSRWLockShared(&session->client->session_lock);
    EnterCriticalSection(&table->lock);

    /* flag the slot as unused */
    if (slotid < NFS41_MAX_NUM_SLOTS && table->used_slots[slotid]) {
        table->used_slots[slotid] = 0;
        table->num_used--;
    }
    /* update highest_used if necessary */
    if (slotid == table->highest_used) {
        while (table->highest_used && !table->used_slots[table->highest_used])
            table->highest_used--;
    }
    dprintf(3, "freeing slot#=%d used=%d highest=%d\n",
        slotid, table->num_used, table->highest_used);

    /* wake any threads waiting on a slot */
    if (slot_table_avail(table))
        WakeAllConditionVariable(&table->cond);

    LeaveCriticalSection(&table->lock);
    ReleaseSRWLockShared(&session->client->session_lock);
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:29,代码来源:nfs41_session.c

示例8: pthread_rwlock_unlock

int pthread_rwlock_unlock(pthread_rwlock_t *l)
{
#ifndef PTHREAD_WIN_XP_SYNC
  void *state = *(void **)l;
	
  if (state == (void *) 1)
    {
      /* Known to be an exclusive lock */
      ReleaseSRWLockExclusive(l);
    }
  else
    {
      /* A shared unlock will work */
      ReleaseSRWLockShared(l);
    }
#else
  WaitForSingleObject(l->mutex,INFINITE);
  if(l->reader_count < 0)	// Known to be an exclusive lock 
    {
      l->reader_count = 0;
      if(l->nb_waiting_writer)	// writter have the priority
	ReleaseSemaphore(l->sema_write,1,NULL);	// Wakeup one writer
      else if(l->nb_waiting_reader)
	ReleaseSemaphore(l->sema_read,l->nb_waiting_reader,NULL); // Wake up all readers
    }
  else if(!--(l->reader_count) && l->nb_waiting_writer)	// maybe wake up one writer
    ReleaseSemaphore(l->sema_write,1,NULL);
  ReleaseMutex(l->mutex);
#endif
  return 0;
}
开发者ID:NexeyaSGara,项目名称:Processlib,代码行数:31,代码来源:pthread_rwlock.cpp

示例9: virtualfs_custom_stat

int virtualfs_custom_stat(struct file *f, struct newstat *buf)
{
	AcquireSRWLockShared(&f->rw_lock);
	struct virtualfs_custom *file = (struct virtualfs_custom *)f;
	struct virtualfs_custom_desc *desc = (struct virtualfs_custom_desc *)file->desc;
	INIT_STRUCT_NEWSTAT_PADDING(buf);
	buf->st_dev = mkdev(0, 1);
	buf->st_ino = 0;
	buf->st_mode = S_IFCHR + 0644;
	buf->st_nlink = 1;
	buf->st_uid = 0;
	buf->st_gid = 0;
	buf->st_rdev = desc->device;
	buf->st_size = 0;
	buf->st_blksize = PAGE_SIZE;
	buf->st_blocks = 0;
	buf->st_atime = 0;
	buf->st_atime_nsec = 0;
	buf->st_mtime = 0;
	buf->st_mtime_nsec = 0;
	buf->st_ctime = 0;
	buf->st_ctime_nsec = 0;
	ReleaseSRWLockShared(&f->rw_lock);
	return 0;
}
开发者ID:AnXi-TieGuanYin-Tea,项目名称:flinux,代码行数:25,代码来源:virtual.c

示例10: cl_exid_compare

static int cl_exid_compare(
    IN const struct list_entry *entry,
    IN const void *value)
{
    nfs41_client *client = client_entry(entry);
    const struct cl_exid_info *info = (const struct cl_exid_info*)value;
    int status = ERROR_FILE_NOT_FOUND;

    AcquireSRWLockShared(&client->exid_lock);

    /* match any of the desired roles */
    if ((info->roles & client->roles) == 0)
        goto out;
    /* match server_owner.major_id */
    if (strncmp(info->exchangeid->server_owner.so_major_id,
        client->server->owner, NFS4_OPAQUE_LIMIT) != 0)
        goto out;
    /* match server_scope */
    if (strncmp(info->exchangeid->server_scope,
        client->server->scope, NFS4_OPAQUE_LIMIT) != 0)
        goto out;
    /* match clientid */
    if (info->exchangeid->clientid != client->clnt_id)
        goto out;

    status = NO_ERROR;
out:
    ReleaseSRWLockShared(&client->exid_lock);
    return status;
}
开发者ID:AchillesA,项目名称:ms-nfs41-client,代码行数:30,代码来源:namespace.c

示例11: winfs_write

static size_t winfs_write(struct file *f, const void *buf, size_t count)
{
	AcquireSRWLockShared(&f->rw_lock);
	struct winfs_file *winfile = (struct winfs_file *) f;
	WaitForSingleObject(winfile->fp_mutex, INFINITE);
	size_t num_written = 0;
	OVERLAPPED overlapped;
	overlapped.Internal = 0;
	overlapped.InternalHigh = 0;
	overlapped.Offset = 0xFFFFFFFF;
	overlapped.OffsetHigh = 0xFFFFFFFF;
	overlapped.hEvent = NULL;
	OVERLAPPED *overlapped_pointer = (f->flags & O_APPEND)? &overlapped: NULL;
	while (count > 0)
	{
		DWORD count_dword = (DWORD)min(count, (size_t)UINT_MAX);
		DWORD num_written_dword;
		if (!WriteFile(winfile->handle, buf, count_dword, &num_written_dword, overlapped_pointer))
		{
			log_warning("WriteFile() failed, error code: %d", GetLastError());
			num_written = -L_EIO;
			break;
		}
		num_written += num_written_dword;
		count -= num_written_dword;
	}
	ReleaseMutex(winfile->fp_mutex);
	ReleaseSRWLockShared(&f->rw_lock);
	return num_written;
}
开发者ID:Logan-lu,项目名称:flinux,代码行数:30,代码来源:winfs.c

示例12: acl_filter

BOOL acl_filter(PACL_LIST acl,const unsigned char HwType,const unsigned char* HwAddr,unsigned char HwAddrLen){
	AcquireSRWLockShared(&acl->lock);
	DEBUG("acl_filter: AcquireSRWLockShared()\n");
	__try{
		char buf[16*2+1];
		DEBUG("acl_filter(HwType=%d, HwAddr=%s)\n",(int)HwType,dhcp_hw_addr(buf,HwAddr,(int)HwAddrLen));
		unsigned int len = acl->length,i,j;
		PACL_ENTRY entries = acl->entry;
		for(i = 0;i<len;i++){
			DEBUG("acl_filter: entry[%d].HwType=%d arg.HwType=%d\n",i,(int)entries[i].HwType,(int)HwType);
			if(entries[i].HwType!=HwType)
				continue;
			
			for(j=0;j<HwAddrLen;j++){
				DEBUG("acl_filter: entry[%d].HwAddr[%d]=0x%02x arg.HwAddr[%d]=0x%02x\n",i,j,(int)entries[i].HwAddr[j],j,(int)HwAddr[j]);
				if((HwAddr[j]&entries[i].HwMask[j])!=entries[i].HwAddr[j]){
					goto next;
				}
			}
			return entries[i].access;
	next:	
			DEBUG("Goto Next\n");
			(void)0;
		}
		return TRUE;
	}__finally{
		ReleaseSRWLockShared(&acl->lock);
		DEBUG("acl_filter: ReleaseSRWLockShared()\n");
	}
}
开发者ID:pengjiang80,项目名称:win32-dhcp-filter-and-logger,代码行数:30,代码来源:acl.cpp

示例13: ReleaseSRWLockShared

/// <summary>
/// Unlocks for reading (Call if thread acquired a read lock).
/// </summary>
void RWLock::UnlockRead()
{
#ifdef PLATFORM_WIN
	ReleaseSRWLockShared( &mRwlock );
#else
	pthread_rwlock_unlock( &mRwlock );
#endif
}
开发者ID:Inch4Tk,项目名称:ModernDB2016SS,代码行数:11,代码来源:RWLock.cpp

示例14: rwlock_rdunlock

void rwlock_rdunlock(rwlock_t *l)
{
#ifndef _WIN32
	atomic_ref(&l->s.write);
#else
	ReleaseSRWLockShared(l);
#endif
}
开发者ID:asamy,项目名称:csnippets,代码行数:8,代码来源:rwlock.c

示例15: virtualfs_char_write

static size_t virtualfs_char_write(struct file *f, const void *buf, size_t count)
{
	AcquireSRWLockShared(&f->rw_lock);
	struct virtualfs_char *file = (struct virtualfs_char *)f;
	size_t r = file->desc->write(file->tag, buf, count);
	ReleaseSRWLockShared(&f->rw_lock);
	return r;
}
开发者ID:AnXi-TieGuanYin-Tea,项目名称:flinux,代码行数:8,代码来源:virtual.c


注:本文中的ReleaseSRWLockShared函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。