rpcs3/rpcs3/Emu/SysCalls/lv2/sleep_queue.h

56 lines
1.1 KiB
C
Raw Normal View History

2014-12-22 23:31:11 +00:00
#pragma once
// attr_protocol (waiting scheduling policy)
enum
{
// First In, First Out
SYS_SYNC_FIFO = 1,
// Priority Order
SYS_SYNC_PRIORITY = 2,
// Basic Priority Inheritance Protocol (probably not implemented)
SYS_SYNC_PRIORITY_INHERIT = 3,
// Not selected while unlocking
SYS_SYNC_RETRY = 4,
//
SYS_SYNC_ATTR_PROTOCOL_MASK = 0xF,
};
// attr_recursive (recursive locks policy)
enum
{
// Recursive locks are allowed
SYS_SYNC_RECURSIVE = 0x10,
// Recursive locks are NOT allowed
SYS_SYNC_NOT_RECURSIVE = 0x20,
//
SYS_SYNC_ATTR_RECURSIVE_MASK = 0xF0, //???
};
2014-12-24 16:09:32 +00:00
class sleep_queue_t
2014-12-22 23:31:11 +00:00
{
std::vector<u32> m_waiting;
std::vector<u32> m_signaled;
2014-12-22 23:31:11 +00:00
std::mutex m_mutex;
2014-12-28 13:15:22 +00:00
std::string m_name;
2014-12-24 16:09:32 +00:00
public:
const u64 name;
2014-12-22 23:31:11 +00:00
sleep_queue_t(u64 name = 0)
2014-12-24 16:09:32 +00:00
: name(name)
2014-12-22 23:31:11 +00:00
{
}
2014-12-24 16:09:32 +00:00
~sleep_queue_t();
2014-12-28 13:15:22 +00:00
void set_full_name(const std::string& name) { m_name = name; }
const std::string& get_full_name() { return m_name; }
2014-12-22 23:31:11 +00:00
void push(u32 tid, u32 protocol);
bool pop(u32 tid, u32 protocol);
u32 signal(u32 protocol);
bool signal_selected(u32 tid);
bool invalidate(u32 tid, u32 protocol);
2014-12-22 23:31:11 +00:00
u32 count();
};