rt: Remove ptr_vec. Unused
This commit is contained in:
parent
4d03e4b711
commit
7d1e36a315
@ -152,34 +152,6 @@ template <typename T> struct region_owned {
|
||||
|
||||
struct rust_cond { };
|
||||
|
||||
// Helper class used regularly elsewhere.
|
||||
|
||||
template <typename T> class ptr_vec : public task_owned<ptr_vec<T> > {
|
||||
static const size_t INIT_SIZE = 8;
|
||||
rust_task *task;
|
||||
size_t alloc;
|
||||
size_t fill;
|
||||
T **data;
|
||||
public:
|
||||
ptr_vec(rust_task *task);
|
||||
~ptr_vec();
|
||||
|
||||
size_t length() {
|
||||
return fill;
|
||||
}
|
||||
|
||||
bool is_empty() {
|
||||
return fill == 0;
|
||||
}
|
||||
|
||||
T *& operator[](size_t offset);
|
||||
void push(T *p);
|
||||
T *pop();
|
||||
T *peek();
|
||||
void trim(size_t fill);
|
||||
void swap_delete(T* p);
|
||||
};
|
||||
|
||||
#include "memory_region.h"
|
||||
#include "rust_srv.h"
|
||||
#include "rust_log.h"
|
||||
|
@ -4,97 +4,6 @@
|
||||
#include "rust_task.h"
|
||||
#include <limits.h>
|
||||
|
||||
// Utility type: pointer-vector.
|
||||
|
||||
template <typename T>
|
||||
ptr_vec<T>::ptr_vec(rust_task *task) :
|
||||
task(task),
|
||||
alloc(INIT_SIZE),
|
||||
fill(0),
|
||||
data(new (task, "ptr_vec<T>") T*[alloc])
|
||||
{
|
||||
I(task->thread, data);
|
||||
DLOG(task->thread, mem, "new ptr_vec(data=0x%" PRIxPTR ") -> 0x%" PRIxPTR,
|
||||
(uintptr_t)data, (uintptr_t)this);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ptr_vec<T>::~ptr_vec()
|
||||
{
|
||||
I(task->thread, data);
|
||||
DLOG(task->thread, mem, "~ptr_vec 0x%" PRIxPTR ", data=0x%" PRIxPTR,
|
||||
(uintptr_t)this, (uintptr_t)data);
|
||||
I(task->thread, fill == 0);
|
||||
task->free(data);
|
||||
}
|
||||
|
||||
template <typename T> T *&
|
||||
ptr_vec<T>::operator[](size_t offset) {
|
||||
I(task->thread, data[offset]->idx == offset);
|
||||
return data[offset];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
ptr_vec<T>::push(T *p)
|
||||
{
|
||||
I(task->thread, data);
|
||||
I(task->thread, fill <= alloc);
|
||||
if (fill == alloc) {
|
||||
alloc *= 2;
|
||||
data = (T **)task->realloc(data, alloc * sizeof(T*));
|
||||
I(task->thread, data);
|
||||
}
|
||||
I(task->thread, fill < alloc);
|
||||
p->idx = fill;
|
||||
data[fill++] = p;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *
|
||||
ptr_vec<T>::pop()
|
||||
{
|
||||
return data[--fill];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *
|
||||
ptr_vec<T>::peek()
|
||||
{
|
||||
return data[fill - 1];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
ptr_vec<T>::trim(size_t sz)
|
||||
{
|
||||
I(task->thread, data);
|
||||
if (sz <= (alloc / 4) &&
|
||||
(alloc / 2) >= INIT_SIZE) {
|
||||
alloc /= 2;
|
||||
I(task->thread, alloc >= fill);
|
||||
data = (T **)task->realloc(data, alloc * sizeof(T*));
|
||||
I(task->thread, data);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
ptr_vec<T>::swap_delete(T *item)
|
||||
{
|
||||
/* Swap the endpoint into i and decr fill. */
|
||||
I(task->thread, data);
|
||||
I(task->thread, fill > 0);
|
||||
I(task->thread, item->idx < fill);
|
||||
fill--;
|
||||
if (fill > 0) {
|
||||
T *subst = data[fill];
|
||||
size_t idx = item->idx;
|
||||
data[idx] = subst;
|
||||
subst->idx = idx;
|
||||
}
|
||||
}
|
||||
|
||||
// Inline fn used regularly elsewhere.
|
||||
|
||||
static inline size_t
|
||||
|
Loading…
x
Reference in New Issue
Block a user