41#pragma clang diagnostic ignored "-Wc++98-compat"
56 std::size_t file_descriptors_manager::size__;
58 io** file_descriptors_manager::descriptors_array__;
72 size__ =
size + reserved__;
73 descriptors_array__ =
new class io*[size__];
77 descriptors_array__[i] =
nullptr;
83 trace::printf (
"file_descriptors_manager::%s(%) @%p\n", __func__,
this);
85 delete[] descriptors_array__;
95 if ((fildes < 0) || (
static_cast<std::size_t
> (fildes) >= size__)
96 || (descriptors_array__ ==
nullptr))
100 return descriptors_array__[fildes];
106 if ((fildes < 0) || (
static_cast<std::size_t
> (fildes) >= size__))
116#if defined(OS_TRACE_POSIX_IO_FILE_DESCRIPTORS_MANAGER)
127 for (std::size_t i = reserved__; i < size__; ++i)
129 if (descriptors_array__[i] ==
nullptr)
131 descriptors_array__[i] =
io;
133#if defined(OS_TRACE_POSIX_IO_FILE_DESCRIPTORS_MANAGER)
137 return static_cast<int> (i);
149 if ((fildes < 0) || (
static_cast<std::size_t
> (fildes) >= size__))
162 descriptors_array__[fildes] =
io;
170#if defined(OS_TRACE_POSIX_IO_FILE_DESCRIPTORS_MANAGER)
171 trace::printf (
"file_descriptors_manager::%s(%d)\n", __func__, fildes);
174 if ((fildes < 0) || (
static_cast<std::size_t
> (fildes) >= size__))
180 descriptors_array__[fildes]->clear_file_descriptor ();
181 descriptors_array__[fildes] =
nullptr;
188 assert((fildes >= 0) && (
static_cast<std::size_t
> (fildes) < size__));
189 auto*
const io = descriptors_array__[fildes];
194 return reinterpret_cast<class
socket*
> (
io);
200 std::size_t count = reserved__;
204 if (descriptors_array__[i] !=
nullptr)
static class socket * socket(int fildes)
~file_descriptors_manager()
static bool valid(int fildes)
static int deallocate(file_descriptor_t fildes)
file_descriptors_manager(std::size_t size)
static int assign(file_descriptor_t fildes, class io *io)
static int allocate(class io *io)
static class io * io(int fildes)
file_descriptor_t file_descriptor(void) const
type_t get_type(void) const
int printf(const char *format,...)
Write a formatted string to the trace device.