Пример #1
0
L4_NS_BEGIN

///////////////////////////////////////////////////////////////////
cub::Status FooAsynAction5::exec(const tsl::TransactionInfo&)
{
    WAIT_ON(EV_EVENT5, handleEvent5);

    return TSL_CONTINUE;
}
Пример #2
0
int PipeWrite(struct File* file,BYTE* buffer,DWORD size)
{
	DWORD free = 0, chars;
	int written = 0;
	int err = 0;
		
	/* If we've got no readers on this pipe, let userspace know. */
	if (PIPE_READERS(file) == 0)
		return -EPIPE;
		
	if (size <= PIPE_BUFFER_SIZE)
		free = size;
	else
		free = 1;
		
	while (size > 0)
	{
		while ((PIPE_FREE(file) < free || PIPE_LOCK(file)))
		{
			if (!PIPE_READERS(file) == 0)
			{
				err = -EPIPE;
				goto out;
			}
			
			if (file->flags & FILE_NONBLOCK)
			{
				goto out;
			}
			
			WAIT_ON(&PIPE_WAIT(file), PIPE_LOCK(file) == 0);
		}
		
		PIPE_LOCK(file)++;
		
		while (size > 0 && (free = PIPE_FREE(file)))
		{
			char* pipeBuf = PIPE_BUF(file) + PIPE_END(file);
			
			chars = PIPE_MAX_WCHUNK(file);
			
			if (chars > size)
				chars = size;
				
			if (chars > free)
				chars = size;
				
			/* Update counters. */
			written += chars;
			PIPE_SIZE(file) += chars;
			size -= chars;
			
			memcpy(pipeBuf, buffer, chars);
			buffer += chars;
		}
		
		PIPE_LOCK(file)--;
		WakeUp(&PIPE_WAIT(file));
		
		free = 1;
	}
	
out:
	return (written > 0) ? (written) : (err);
}