@@ -2849,7 +2849,7 @@ void thread_ctrl::set_native_priority(int priority)
|
||||
|
||||
if (int err = pthread_setschedparam(pthread_self(), policy, ¶m))
|
||||
{
|
||||
sig_log.error("pthraed_setschedparam() failed: %d", err);
|
||||
sig_log.error("pthread_setschedparam() failed: %d", err);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -5,6 +5,34 @@ simple_ringbuf::simple_ringbuf(u32 size)
|
||||
set_buf_size(size);
|
||||
}
|
||||
|
||||
simple_ringbuf::simple_ringbuf(simple_ringbuf&& other)
|
||||
{
|
||||
rw_ptr = other.rw_ptr.load();
|
||||
buf_size = other.buf_size;
|
||||
buf = std::move(other.buf);
|
||||
initialized = other.initialized.observe();
|
||||
|
||||
other.buf_size = 0;
|
||||
other.rw_ptr = 0;
|
||||
other.initialized = false;
|
||||
}
|
||||
|
||||
simple_ringbuf& simple_ringbuf::operator=(simple_ringbuf&& other)
|
||||
{
|
||||
if (this == &other) return *this;
|
||||
|
||||
rw_ptr = other.rw_ptr.load();
|
||||
buf_size = other.buf_size;
|
||||
buf = std::move(other.buf);
|
||||
initialized = other.initialized.observe();
|
||||
|
||||
other.buf_size = 0;
|
||||
other.rw_ptr = 0;
|
||||
other.initialized = false;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
u32 simple_ringbuf::get_free_size()
|
||||
{
|
||||
const u64 _rw_ptr = rw_ptr;
|
||||
@@ -19,6 +47,11 @@ u32 simple_ringbuf::get_used_size()
|
||||
return buf_size - 1 - get_free_size();
|
||||
}
|
||||
|
||||
u32 simple_ringbuf::get_total_size()
|
||||
{
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
void simple_ringbuf::set_buf_size(u32 size)
|
||||
{
|
||||
ensure(size);
|
||||
|
||||
@@ -19,8 +19,15 @@ public:
|
||||
simple_ringbuf() {};
|
||||
simple_ringbuf(u32 size);
|
||||
|
||||
simple_ringbuf(const simple_ringbuf&) = delete;
|
||||
simple_ringbuf& operator=(const simple_ringbuf&) = delete;
|
||||
|
||||
simple_ringbuf(simple_ringbuf&& other);
|
||||
simple_ringbuf& operator=(simple_ringbuf&& other);
|
||||
|
||||
u32 get_free_size();
|
||||
u32 get_used_size();
|
||||
u32 get_total_size();
|
||||
|
||||
// Thread unsafe functions.
|
||||
void set_buf_size(u32 size);
|
||||
|
||||
Reference in New Issue
Block a user