Cleanup semaphore<> (sema.h) and mutex.h (shared_mutex)

Remove semaphore_lock and writer_lock classes, replace with std::lock_guard
Change semaphore<> interface to Lockable (+ exotic try_unlock method)
This commit is contained in:
Nekotekina 2018-09-03 22:28:33 +03:00
parent 5e556a87ff
commit ca5158a03e
50 changed files with 283 additions and 382 deletions

View file

@ -134,7 +134,7 @@ struct vdec_thread : ppu_thread
AVDictionary* opts{};
av_dict_set(&opts, "refcounted_frames", "1", 0);
std::lock_guard<std::mutex> lock(g_mutex_avcodec_open2);
std::lock_guard lock(g_mutex_avcodec_open2);
int err = avcodec_open2(ctx, codec, &opts);
if (err || opts)
@ -354,7 +354,7 @@ struct vdec_thread : ppu_thread
cellVdec.trace("Got picture (pts=0x%llx[0x%llx], dts=0x%llx[0x%llx])", frame.pts, frame->pkt_pts, frame.dts, frame->pkt_dts);
std::lock_guard<std::mutex>{mutex}, out.push(std::move(frame));
std::lock_guard{mutex}, out.push(std::move(frame));
cb_func(*this, id, CELL_VDEC_MSG_TYPE_PICOUT, CELL_OK, cb_arg);
lv2_obj::sleep(*this);
@ -377,7 +377,7 @@ struct vdec_thread : ppu_thread
au_count--;
}
while (std::lock_guard<std::mutex>{mutex}, max_frames && out.size() > max_frames)
while (std::lock_guard{mutex}, max_frames && out.size() > max_frames)
{
thread_ctrl::wait();
}
@ -494,7 +494,7 @@ s32 cellVdecClose(ppu_thread& ppu, u32 handle)
lv2_obj::sleep(ppu);
{
std::lock_guard<std::mutex> lock(vdec->mutex);
std::lock_guard lock(vdec->mutex);
vdec->cmd_push({vdec_cmd::close, 0});
vdec->max_frames = 0;
}
@ -583,7 +583,7 @@ s32 cellVdecGetPicture(u32 handle, vm::cptr<CellVdecPicFormat> format, vm::ptr<u
vdec_frame frame;
{
std::lock_guard<std::mutex> lock(vdec->mutex);
std::lock_guard lock(vdec->mutex);
if (vdec->out.empty())
{
@ -713,7 +713,7 @@ s32 cellVdecGetPicItem(u32 handle, vm::pptr<CellVdecPicItem> picItem)
u64 usrd;
u32 frc;
{
std::lock_guard<std::mutex> lock(vdec->mutex);
std::lock_guard lock(vdec->mutex);
if (vdec->out.empty())
{