本文整理汇总了C++中mem_func_ptr_t::async方法的典型用法代码示例。如果您正苦于以下问题:C++ mem_func_ptr_t::async方法的具体用法?C++ mem_func_ptr_t::async怎么用?C++ mem_func_ptr_t::async使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mem_func_ptr_t
的用法示例。
在下文中一共展示了mem_func_ptr_t::async方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fsAioRead
void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*)(mem_ptr_t<CellFsAio> xaio, int error, int xid, u64 size)> func)
{
while (g_FsAioReadCur != xid)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
if (Emu.IsStopped())
{
LOG_WARNING(HLE, "fsAioRead() aborted");
return;
}
}
vfsFileBase* orig_file;
if(!sys_fs->CheckId(fd, orig_file)) return;
u64 nbytes = aio->size;
u32 buf_addr = aio->buf_addr;
u32 error = CELL_OK;
vfsStream& file = *(vfsStream*)orig_file;
const u64 old_pos = file.Tell();
file.Seek((u64)aio->offset);
// TODO: use code from cellFsRead or something
u64 res = 0;
if (nbytes != (u32)nbytes)
{
error = CELL_ENOMEM;
}
else
{
res = nbytes ? file.Read(Memory.GetMemFromAddr(buf_addr), nbytes) : 0;
}
file.Seek(old_pos);
if (Ini.HLELogging.GetValue())
LOG_NOTICE(HLE, "*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=0x%x, error=0x%x, res=0x%x, xid=0x%x [%s])",
fd, (u64)aio->offset, buf_addr, (u64)aio->size, error, res, xid, orig_file->GetPath().c_str());
if (func) // start callback thread
{
func.async(aio, error, xid, res);
}
g_FsAioReadCur++;
}
示例2: fsAioRead
void fsAioRead(u32 fd, mem_ptr_t<CellFsAio> aio, int xid, mem_func_ptr_t<void (*)(mem_ptr_t<CellFsAio> xaio, int error, int xid, u64 size)> func)
{
while (g_FsAioReadCur != xid)
{
Sleep(1);
if (Emu.IsStopped())
{
ConLog.Warning("fsAioRead() aborted");
return;
}
}
vfsFileBase* orig_file;
if(!sys_fs.CheckId(fd, orig_file)) return;
std::string path = orig_file->GetPath();
std::string::size_type first_slash = path.find('/');
if (first_slash == std::string::npos)
{
path = "";
}
else
{
path = path.substr(first_slash+1,std::string::npos);
}
u64 nbytes = aio->size;
u32 buf_addr = aio->buf_addr;
u32 res = 0;
u32 error = CELL_OK;
vfsStream& file = *(vfsStream*)orig_file;
const u64 old_pos = file.Tell();
file.Seek((u64)aio->offset);
u32 count = nbytes;
if (nbytes != (u64)count)
{
error = CELL_ENOMEM;
goto fin;
}
if (!Memory.IsGoodAddr(buf_addr))
{
error = CELL_EFAULT;
goto fin;
}
if (count) if (u32 frag = buf_addr & 4095) // memory page fragment
{
u32 req = min(count, 4096 - frag);
u32 read = file.Read(Memory + buf_addr, req);
buf_addr += req;
res += read;
count -= req;
if (read < req) goto fin;
}
for (u32 pages = count / 4096; pages > 0; pages--) // full pages
{
if (!Memory.IsGoodAddr(buf_addr)) goto fin; // ??? (probably EFAULT)
u32 read = file.Read(Memory + buf_addr, 4096);
buf_addr += 4096;
res += read;
count -= 4096;
if (read < 4096) goto fin;
}
if (count) // last fragment
{
if (!Memory.IsGoodAddr(buf_addr)) goto fin;
res += file.Read(Memory + buf_addr, count);
}
fin:
file.Seek(old_pos);
ConLog.Warning("*** fsAioRead(fd=%d, offset=0x%llx, buf_addr=0x%x, size=0x%x, error=0x%x, res=0x%x, xid=0x%x [%s])",
fd, (u64)aio->offset, buf_addr, (u64)aio->size, error, res, xid, path.c_str());
if (func) // start callback thread
{
func.async(aio, error, xid, res);
}
/*CPUThread& thr = Emu.GetCallbackThread();
while (thr.IsAlive())
{
Sleep(1);
if (Emu.IsStopped())
{
ConLog.Warning("fsAioRead() aborted");
break;
}
}*/
g_FsAioReadCur++;
}
示例3: cellMsgDialogOpen2
//.........这里部分代码省略.........
if (m_gauge1)
{
sizer1->Add(m_text1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8);
sizer1->Add(m_gauge1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16);
m_gauge1->SetValue(0);
}
if (m_gauge2)
{
sizer1->Add(m_text2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8);
sizer1->Add(m_gauge2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16);
m_gauge2->SetValue(0);
}
wxBoxSizer* buttons = new wxBoxSizer(wxHORIZONTAL);
switch (type & CELL_MSGDIALOG_TYPE_BUTTON_TYPE)
{
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_NONE:
break;
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO:
m_button_yes = new wxButton(g_msg_dialog, wxID_YES);
buttons->Add(m_button_yes, 0, wxALIGN_CENTER_HORIZONTAL | wxRIGHT, 8);
m_button_no = new wxButton(g_msg_dialog, wxID_NO);
buttons->Add(m_button_no, 0, wxALIGN_CENTER_HORIZONTAL, 16);
sizer1->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
break;
case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK:
m_button_ok = new wxButton(g_msg_dialog, wxID_OK);
buttons->Add(m_button_ok, 0, wxALIGN_CENTER_HORIZONTAL, 16);
sizer1->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16);
break;
}
sizer1->AddSpacer(16);
g_msg_dialog->SetSizerAndFit(sizer1);
g_msg_dialog->Centre(wxBOTH);
g_msg_dialog->Show();
g_msg_dialog->Enable();
g_msg_dialog->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event)
{
status = (event.GetId() == wxID_NO) ? CELL_MSGDIALOG_BUTTON_NO : CELL_MSGDIALOG_BUTTON_YES /* OK */;
g_msg_dialog->Hide();
m_wait_until = get_system_time();
g_msg_dialog_state = msgDialogClose;
});
g_msg_dialog->Bind(wxEVT_CLOSE_WINDOW, [&](wxCloseEvent& event)
{
if (type & CELL_MSGDIALOG_TYPE_DISABLE_CANCEL)
{
}
else
{
status = CELL_MSGDIALOG_BUTTON_ESCAPE;
g_msg_dialog->Hide();
m_wait_until = get_system_time();
g_msg_dialog_state = msgDialogClose;
}
});
m_signal = true;
});
while (!m_signal)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
while (g_msg_dialog_state == msgDialogOpen || get_system_time() < m_wait_until)
{
if (Emu.IsStopped())
{
g_msg_dialog_state = msgDialogAbort;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
if (callback && (g_msg_dialog_state != msgDialogAbort))
callback.async(status, userData);
wxGetApp().CallAfter([&]()
{
delete g_msg_dialog;
g_msg_dialog = nullptr;
});
g_msg_dialog_state = msgDialogNone;
});
t.detach();
return CELL_OK;
}