network/stack: Remove unused "Fifo" class.

Its declarations were moved from another header to this file
in 2008, with a comment in the commit message and a TODO here
questioning whether it was needed for anything. In the 15 years
since then, nothing has used it.
This commit is contained in:
Augustin Cavalier 2023-11-22 11:47:52 -05:00
parent 4100480724
commit 0b829b1151

View File

@ -28,38 +28,6 @@
#endif
// internal Fifo class which doesn't maintain it's own lock
// TODO: do we need this one for anything?
class Fifo {
public:
Fifo(const char* name, size_t maxBytes);
~Fifo();
status_t InitCheck() const;
status_t Enqueue(net_buffer* buffer);
status_t EnqueueAndNotify(net_buffer* _buffer, net_socket* socket,
uint8 event);
status_t Wait(mutex* lock, bigtime_t timeout);
net_buffer* Dequeue(bool clone);
status_t Clear();
void WakeAll();
bool IsEmpty() const { return current_bytes == 0; }
//private:
// these field names are kept so we can use templatized
// functions together with net_fifo
sem_id notify;
int32 waiting;
size_t max_bytes;
size_t current_bytes;
struct list buffers;
};
static struct list sTimers;
static mutex sTimerLock;
static sem_id sTimerWaitSem;
@ -234,102 +202,6 @@ notify_socket(net_socket* socket, uint8 event, int32 value)
}
// #pragma mark - FIFOs
Fifo::Fifo(const char* name, size_t maxBytes)
{
base_fifo_init(this, name, maxBytes);
}
Fifo::~Fifo()
{
Clear();
delete_sem(notify);
}
status_t
Fifo::InitCheck() const
{
return !(notify < B_OK);
}
status_t
Fifo::Enqueue(net_buffer* buffer)
{
return base_fifo_enqueue_buffer(this, buffer);
}
status_t
Fifo::EnqueueAndNotify(net_buffer* _buffer, net_socket* socket, uint8 event)
{
net_buffer *buffer = gNetBufferModule.clone(_buffer, false);
if (buffer == NULL)
return B_NO_MEMORY;
status_t status = Enqueue(buffer);
if (status < B_OK)
gNetBufferModule.free(buffer);
else
notify_socket(socket, event, current_bytes);
return status;
}
status_t
Fifo::Wait(mutex* lock, bigtime_t timeout)
{
waiting++;
mutex_unlock(lock);
status_t status = acquire_sem_etc(notify, 1,
B_CAN_INTERRUPT | B_ABSOLUTE_TIMEOUT, timeout);
mutex_lock(lock);
return status;
}
net_buffer*
Fifo::Dequeue(bool clone)
{
net_buffer* buffer = (net_buffer*)list_get_first_item(&buffers);
// assert(buffer != NULL);
if (clone) {
buffer = gNetBufferModule.clone(buffer, false);
fifo_notify_one_reader(waiting, notify);
}else {
list_remove_item(&buffers, buffer);
current_bytes -= buffer->size;
}
return buffer;
}
status_t
Fifo::Clear()
{
return base_fifo_clear(this);
}
void
Fifo::WakeAll()
{
#ifdef __HAIKU__
release_sem_etc(notify, 0, B_RELEASE_ALL);
#else
release_sem_etc(notify, 0, waiting);
#endif
}
status_t
init_fifo(net_fifo* fifo, const char* name, size_t maxBytes)
{