コード例 #1
0
ファイル: ring_fifo.c プロジェクト: felipe-lavratti/chelper
bool ring_fifo_is_full(ring_fifo_t *cobj)
{
	struct s_ring_fifo_private * obj = (struct s_ring_fifo_private *)cobj;
	PTR_CHECK_RETURN(obj, "ring_fifo", false);

	return _full(obj);
}
コード例 #2
0
ファイル: ring_fifo.c プロジェクト: felipe-lavratti/chelper
BUFFER_PTR ring_fifo_zerocopy_push_start(ring_fifo_t * cobj)
{
	struct s_ring_fifo_private * obj = (struct s_ring_fifo_private *)cobj;
	PTR_CHECK_RETURN(obj, "ring_fifo", NULL);

	if (_full(obj))
		return NULL;

	obj->nocp_push_started = true;

	return _wr_ptr(obj);
}
コード例 #3
0
ファイル: LuaRunBuffer.cpp プロジェクト: carlsonp/vr-jugglua
    bool LuaRunBuffer::addString(const std::string &str, bool blocking) {
        if (!_script.isValid()) {
            VRJLUA_MSG_START(dbgVRJLUA_BUFFER, MSG_WARNING)
                << "in AddString, but init not run with a valid LuaScript "
                   "state!" << VRJLUA_MSG_END(dbgVRJLUA_BUFFER, MSG_WARNING);
            return false;
        }
        vpr::Guard<vpr::CondVar> guard(_cond, blocking);
        if (guard.locked()) {

            if (!blocking) {
                // Non-blocking case: If it's full, bail out
                if (_full()) {
                    VRJLUA_MSG_START(dbgVRJLUA_BUFFER, MSG_STATUS)
                        << "Buffer full, so returning false..."
                        << VRJLUA_MSG_END(dbgVRJLUA_BUFFER, MSG_STATUS);
                    return false;
                }
            } else {
                // Blocking case: wait on the condition variable
                while (_full()) {
                    _cond.wait();
                }
            }

            // OK, so we have space.  Put it in, increase the number,
            // and get out of this critical region!
            _buf.push_back(str);
            return true;
        } else {
            VRJLUA_MSG_START(dbgVRJLUA_BUFFER, MSG_STATUS)
                << "Could not acquire buffer lock for producing, returning "
                   "false..." << VRJLUA_MSG_END(dbgVRJLUA_BUFFER, MSG_STATUS);
            return false;
        }
    }
コード例 #4
0
ファイル: ring_fifo.c プロジェクト: felipe-lavratti/chelper
bool ring_fifo_push(ring_fifo_t *cobj, BUFFER_PTR_RDOLY copy_src)
{
	struct s_ring_fifo_private * obj = (struct s_ring_fifo_private *)cobj;
	PTR_CHECK_RETURN(obj, "ring_fifo", false);

	if (_full(obj))
		return false;

	if (!copy_src)
		return false;

	memcpy(_wr_ptr(obj), copy_src, obj->element_size);

	obj->wr++;

	return true;
}