Redian新闻
>
Re: "你悲愤也没有用" 怎么翻译? (转载)
avatar
Re: "你悲愤也没有用" 怎么翻译? (转载)# Joke - 肚皮舞运动
d*u
1
Here are 3 programs I would like you to write in C++. Each one builds on the
last.
Step 1: Write a Job Handler class that can handle multiple Requests that are
trying to access a single Resource. Each Resource can only be allocated by
one Request at a time. The requests should be handled in the order in which
they are received by the Job Handler.
Step 2: Extend this class to handle multiple Resources.
Step 3: Do not allow the same Requestor to submit a Request for two
Resources simultaneously.
avatar
F*n
2
我是说用其他的卡(2%和不到2%的)。这个deal现在越搞越大,估计活不长了
avatar
g*f
3
【 以下文字转载自 WaterWorld 讨论区 】
发信人: freeyun2000 (清扬婉兮), 信区: WaterWorld
标 题: Re: "你悲愤也没有用" 怎么翻译?
发信站: BBS 未名空间站 (Thu Jun 30 17:46:38 2011, 美东)
直译:You have nothing to do about it.
意译:Go back to your China (老将)Go to hell (小将)
avatar
i*h
4
写个简单的意思意思:
class JobHandler
{
public:
JobHandler(ResourceManager*);
~JobHandler();
void Receive(Request&); //receive request and insert into queue, atomic
void Run();

private:
queue m_queue;
ResourceManager* m_ResMgr;
}
//Thread1 function
//This is the main loop of processing thread
void JobHandler::Run()
{
while(true)
{
lock_queue();
if(m_queue.empty())
{
//better to optimize here so that we don't frequently lock/
unlock.
unlock_queue();
continue;
}
Request& req = m_queue.front();
m_queue.pop_front();
unlock_queue();
m_ResMgr->Handle(req);
}
}
//Thread2 function
//call this in receiver thread's main loop.
void JobHandler::Receive(Request& r)
{
//assuming queue won't full. better to handle this.
lock_queue();
m_queue.push_back(r);
unlock_queue();
}
class ResourceManager doesn't need to be multi-threading safe because calls
to it have already been serialized.
avatar
g*t
5
Whining does not help
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。