-#include <xpool/xpool.h>
+#include <xtypes/xpool.h>
//#include <xpool.h>
//#include <xseg/xseg.h>
void xpool_clear(struct xpool *xp, uint32_t who)
{
- xq_acquire(&xp->lock, who);
+ xlock_acquire(&xp->lock, who);
__xpool_clear(xp);
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
}
void xpool_init(struct xpool *xp, uint64_t size, struct xpool_node* mem)
{
xp->size = size;
XPTRSET(&xp->mem, mem);
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
__xpool_clear(xp);
}
xpool_index xpool_add(struct xpool *xp, xpool_data data, uint32_t who)
{
xpool_index idx;
- xq_acquire(&xp->lock, who);
+ xlock_acquire(&xp->lock, who);
idx = __xpool_add(xp, data);
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return idx;
}
/*
{
struct xpool_node *new, *list, *free, *next, *prev;
//acquire lock
- xq_acquire(&xp->lock, 1);
+ xlock_acquire(&xp->lock, 1);
free = XPTR(&xp->free);
list = XPTR(&xp->list);
new = free;
if (new == NULL){
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return NoIndex;
}
free = XPTR(&new->next);
}
new->data = data;
//release lock
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return (new - XPTR(&xp->mem));
}
*/
{
struct xpool_node *node, *list, *free, *prev, *next;
//acquire lock
- xq_acquire(&xp->lock, 1);
+ xlock_acquire(&xp->lock, 1);
if (!__validate_idx(xp, idx)){ // idx < xp->size && node->prev != NULL
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return NoIndex;
}
node = XPTR(&xp->mem) + idx;
//xp->free = node;
//release lock
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return idx;
}
*/
xpool_index xpool_remove(struct xpool *xp, xpool_index idx, xpool_data *data, uint32_t who)
{
xpool_index ret;
- xq_acquire(&xp->lock, who);
+ xlock_acquire(&xp->lock, who);
ret = __xpool_remove(xp, idx, data);
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return ret;
}
xpool_index xpool_peek(struct xpool *xp, xpool_data *data, uint32_t who)
{
xpool_index ret;
- xq_acquire(&xp->lock, who);
+ xlock_acquire(&xp->lock, who);
ret = __xpool_peek(xp, data);
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return ret;
}
xpool_index xpool_peek_idx(struct xpool *xp, xpool_index idx, xpool_data *data, uint32_t who)
{
xpool_index ret;
- xq_acquire(&xp->lock, who);
+ xlock_acquire(&xp->lock, who);
ret = __xpool_peek_idx(xp,idx,data);
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return ret;
}
xpool_index xpool_peek_and_fwd(struct xpool *xp, xpool_data *data, uint32_t who)
{
xpool_index ret;
- xq_acquire(&xp->lock, who);
+ xlock_acquire(&xp->lock, who);
ret = __xpool_peek_and_fwd(xp,data);
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return ret;
}
{
struct xpool_node *list, *next;
//acquire lock
- xq_acquire(&xp->lock, 1);
+ xlock_acquire(&xp->lock, 1);
list = XPTR(&xp->list);
if (!list){
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return NoIndex;
}
*data = list->data;
XPTRSET(&xp->list, next);
//xp->list = xp->list->next;
//release lock
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return (list - XPTR(&xp->mem));
}
*/
xpool_index xpool_set_idx(struct xpool *xp, xpool_index idx, xpool_data data, uint32_t who)
{
xpool_index ret;
- xq_acquire(&xp->lock, who);
+ xlock_acquire(&xp->lock, who);
ret = __xpool_set_idx(xp, idx, data);
- xq_release(&xp->lock);
+ xlock_release(&xp->lock);
return ret;
}