本文整理汇总了C++中WorkQueue类的典型用法代码示例。如果您正苦于以下问题:C++ WorkQueue类的具体用法?C++ WorkQueue怎么用?C++ WorkQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WorkQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
WorkQueue q;
work_t w = work_t(1, 2, 3, 4);
q.add(w);
assert(q.get().bot_y == w.bot_y);
assert(q.get().id == 0);
assert(q.remove(0).bot_y == w.bot_y);
return 0;
}
示例2: ASSERT_ARG
DWORD WorkQueue::workThreadCallback(void* context)
{
ASSERT_ARG(context, context);
WorkQueue* queue = static_cast<WorkQueue*>(context);
if (!queue->tryRegisterAsWorkThread())
return 0;
queue->performWorkOnRegisteredWorkThread();
return 0;
}
示例3: printWorkQueue
void printWorkQueue(WorkQueue& queue) {
WorkQueue local_queue(queue);
printf("WorkQueue: %d elements\n", queue.size());
for (long unsigned int request_index = 0;
request_index < queue.size();
++request_index) {
WorkRequest req = local_queue.top();
local_queue.pop();
printf("queue[%d]: node_index: %d, time_diff: %f\n", request_index,
req.getIndex(), req.getTimeDiff());
}
}
示例4: mID
//---------------------------------------------------------------------
Page::Page(PageID pageID, PagedWorldSection* parent)
: mID(pageID)
, mParent(parent)
, mDeferredProcessInProgress(false)
, mModified(false)
, mDebugNode(0)
{
WorkQueue* wq = Root::getSingleton().getWorkQueue();
mWorkQueueChannel = wq->getChannel("Ogre/Page");
wq->addRequestHandler(mWorkQueueChannel, this);
wq->addResponseHandler(mWorkQueueChannel, this);
touch();
}
示例5: renderFinished
void Scheduler::renderFinished(WorkItem* item)
{
WorkQueue* temp = priorityList.first();
bool containsItem = false;
if(item)
{
while((temp)&&(!containsItem))
{
containsItem = temp->renderFinished(item);
temp = priorityList.next();
}
}
}
示例6: Component
Octree::Octree(Context* context) :
Component(context),
Octant(BoundingBox(-DEFAULT_OCTREE_SIZE, DEFAULT_OCTREE_SIZE), 0, 0, this),
numLevels_(DEFAULT_OCTREE_LEVELS)
{
// Resize threaded ray query intermediate result vector according to number of worker threads
WorkQueue* workQueue = GetSubsystem<WorkQueue>();
rayQueryResults_.Resize(workQueue ? workQueue->GetNumThreads() + 1 : 1);
// If the engine is running headless, subscribe to RenderUpdate events for manually updating the octree
// to allow raycasts and animation update
if (!GetSubsystem<Graphics>())
SubscribeToEvent(E_RENDERUPDATE, HANDLER(Octree, HandleRenderUpdate));
}
示例7: data
//------------------------------------------------------------------------
BackgroundProcessTicket ResourceBackgroundQueue::addRequest(ResourceRequest& req)
{
WorkQueue* queue = Root::getSingleton().getWorkQueue();
Any data(req);
WorkQueue::RequestID requestID =
queue->addRequest(mWorkQueueChannel, (uint16)req.type, data);
mOutstandingRequestSet.insert(requestID);
return requestID;
}
示例8: TEST
TEST(WorkQueue, cancel) {
RunLoop loop(uv_default_loop());
WorkQueue queue;
auto work = [&]() {
FAIL() << "Should never be called";
};
queue.push(work);
queue.push(work);
queue.push(work);
queue.push(work);
queue.push(work);
}
示例9: workitems
void MethodTransform::sync_all() {
std::vector<MethodTransform*> transforms;
for (auto& centry : s_cache) {
transforms.push_back(centry.second);
}
std::vector<WorkItem<MethodTransform>> workitems(transforms.size());
auto mt_sync = [](MethodTransform* mt) { mt->sync(); };
for (size_t i = 0; i < transforms.size(); i++) {
workitems[i].init(mt_sync, transforms[i]);
}
WorkQueue wq;
if (workitems.size() > 0) {
wq.run_work_items(&workitems[0], (int)workitems.size());
}
}
示例10: lk
StatusWith<ReplicationExecutor::CallbackHandle> ReplicationExecutor::scheduleWorkAt(
Date_t when,
const CallbackFn& work) {
boost::lock_guard<boost::mutex> lk(_mutex);
WorkQueue temp;
StatusWith<CallbackHandle> cbHandle = enqueueWork_inlock(&temp, work);
if (!cbHandle.isOK())
return cbHandle;
cbHandle.getValue()._iter->readyDate = when;
WorkQueue::iterator insertBefore = _sleepersQueue.begin();
while (insertBefore != _sleepersQueue.end() && insertBefore->readyDate <= when)
++insertBefore;
_sleepersQueue.splice(insertBefore, temp, temp.begin());
return cbHandle;
}
示例11: test_work_queue
void test_work_queue() {
WorkQueue<string> q;
string t = "hello";
q.push(t);
string s;
if(q.try_pop(s, 500)){
cout << "got " << s << " from queue" << endl;
}
bool ok = q.try_pop(s,500);
if(ok) {
cout << "failed, should have timed out" << endl;
}
else{
cout << "passed, timed out as expected" << endl;
}
}
示例12: didCloseOnConnectionWorkQueue
static void didCloseOnConnectionWorkQueue(WorkQueue& workQueue, CoreIPC::Connection*)
{
// If the connection has been closed and we haven't responded in the main thread for 10 seconds
// the process will exit forcibly.
const double watchdogDelay = 10;
workQueue.dispatchAfterDelay(bind(static_cast<void(*)()>(watchdogCallback)), watchdogDelay);
}
示例13: didCloseOnConnectionWorkQueue
void ChildProcess::didCloseOnConnectionWorkQueue(WorkQueue& workQueue, CoreIPC::Connection*)
{
// If the connection has been closed and we haven't responded in the main thread for 10 seconds
// the process will exit forcibly.
static const double watchdogDelay = 10.0;
workQueue.scheduleWorkAfterDelay(WorkItem::create(watchdogCallback), watchdogDelay);
}
示例14: PagedWorldSection
//---------------------------------------------------------------------
TerrainPagedWorldSection::TerrainPagedWorldSection(const String& name, PagedWorld* parent, SceneManager* sm)
: PagedWorldSection(name, parent, sm)
, mTerrainGroup(0)
, mTerrainDefiner(0)
, mHasRunningTasks(false)
, mLoadingIntervalMs(900)
{
// we always use a grid strategy
setStrategy(parent->getManager()->getStrategy("Grid2D"));
WorkQueue* wq = Root::getSingleton().getWorkQueue();
mWorkQueueChannel = wq->getChannel("Ogre/TerrainPagedWorldSection");
wq->addRequestHandler(mWorkQueueChannel, this);
wq->addResponseHandler(mWorkQueueChannel, this);
mNextLoadingTime = Root::getSingletonPtr()->getTimer()->getMilliseconds();
}
示例15: FastqWriterThread
Results FastqWriterThread(WorkQueue<Results>& queue, const string& fname)
{
ofstream ccsFastq(fname);
Results counts;
while (queue.ConsumeWith(WriteFastqRecords, ref(ccsFastq), ref(counts)))
;
return counts;
}