void PackagePropertiesDialog::onDataChanged(TransferItem *package, int role) {
    switch (role) {
    case TransferItem::CategoryRole:
        updateCategory(package);
        break;
    case TransferItem::CreateSubfolderRole:
        updateCreateSubfolder(package);
        break;
    case TransferItem::NameRole:
        updateName(package);
        break;
    case TransferItem::PriorityRole:
        updatePriority(package);
        break;
    case TransferItem::ProgressRole:
    case TransferItem::RowCountRole:
        updateProgress(package);
        break;
    case TransferItem::StatusRole:
        updateStatus(package);
        break;
    default:
        break;
    }
}
bool LLAudioSource::setupChannel()
{
	LLAudioData *adp = getCurrentData();

	if (!adp->getBuffer())
	{
		// We're not ready to play back the sound yet, so don't try and allocate a channel for it.
		//llwarns << "Aborting, no buffer" << llendl;
		return false;
	}


	if (!mChannelp)
	{
		// Update the priority, in case we need to push out another channel.
		updatePriority();

		setChannel(gAudiop->getFreeChannel(getPriority()));
	}

	if (!mChannelp)
	{
		// Ugh, we don't have any free channels.
		// Now we have to reprioritize.
		// For now, just don't play the sound.
		//llwarns << "Aborting, no free channels" << llendl;
		return false;
	}

	mChannelp->setSource(this);
	return true;
}
int thread_yield(){

#ifdef O_PREEMPTION
  interruptsOff();
#endif
  
  //le thread courant
  thread *th1 = getRunningThread();
  //le prochain thread
  thread *th2 = prochainThread();

#ifdef O_PRIORITE
  updatePriority(th1);
#endif

#ifdef O_PREEMTION
  setAlarm();
#endif   
  if(th2->tid != th1->tid){
    addInFifo(th1);
    setRunningThread(th2);
#ifdef O_PREEMPTION
  interruptsOn();
#endif
    swapcontext(th1->context,th2->context);
  }
  return 0;
}
TEST_F(QueueTest, UpdateParentDescendant) {
  buildSimpleTree();

  updatePriority(1, {5, false, 8});
  dump();

  EXPECT_EQ(nodes_, IDList({{5, 100}, {9, 50}, {1, 50}, {3, 33}, {7, 66}}));
}
TEST_F(QueueTest, UpdateParentAncestorExcl) {
  buildSimpleTree();

  updatePriority(9, {0, true, 16});
  dump();

  EXPECT_EQ(nodes_, IDList({{9, 100}, {1, 100}, {3, 25}, {5, 25}, {7, 50}}));
}
TEST_F(QueueTest, UpdateWeightExcl) {
  buildSimpleTree();

  updatePriority(5, {1, true, 8});
  dump();

  EXPECT_EQ(nodes_, IDList({{1, 100}, {5, 100}, {9, 40}, {3, 20}, {7, 40}}));
}
void HumanAINeedComponent::updateStats()
{
    updateFulfillment();
    _fulfillment = boost::algorithm::clamp(_fulfillment, 0.0f, 1.0f);
    updatePriority();
    _priority = boost::algorithm::clamp(_priority, 0.0f, 100.0f);
    _lastUpdateTime = _dayTime->getCurrentGameDate().time;
}
TEST_F(QueueTest, UpdateParentDescendantExcl) {
  buildSimpleTree();

  updatePriority(1, {5, true, 8});
  dump();

  EXPECT_EQ(nodes_, IDList({{5, 100}, {1, 100}, {3, 20}, {7, 40}, {9, 40}}));
}
TEST_F(QueueTest, UpdateParentSiblingExcl) {
  buildSimpleTree();

  updatePriority(7, {5, true, 4});
  dump();

  EXPECT_EQ(nodes_, IDList({{1, 100}, {3, 50}, {5, 50},
                              {7, 100}, {9, 100}}));
}
TEST_F(QueueTest, UpdateParentSibling) {
  buildSimpleTree();

  updatePriority(5, {3, false, 4});
  dump();

  EXPECT_EQ(nodes_, IDList({{1, 100}, {3, 33}, {5, 100},
                               {9, 100}, {7, 66}}));
}
TEST_F(QueueTest, UpdateParentAncestor) {
  buildSimpleTree();

  updatePriority(9, {0, false, 15});
  dump();

  EXPECT_EQ(nodes_, IDList({{1, 50}, {3, 25}, {5, 25}, {7, 50}, {9, 50}}));
  nextEgress();
  EXPECT_EQ(nodes_, IDList({{1, 50}, {9, 50}}));
}
TEST_F(QueueTest, UpdateWeightExclDequeued) {
  buildSimpleTree();

  signalEgress(5, false);
  updatePriority(5, {1, true, 7});
  signalEgress(1, false);
  nextEgress();

  EXPECT_EQ(nodes_, IDList({{9, 40}, {7, 40}, {3, 20}}));
}
TEST_F(QueueTest, UpdateWeightNotEnqueued) {
  addTransaction(1, {0, false, 7});
  addTransaction(3, {0, false, 7});

  signalEgress(1, false);
  signalEgress(3, false);
  updatePriority(1, {3, false, 7});
  dump();

  EXPECT_EQ(nodes_, IDList({{3, 100}, {1, 100}}));
}
PackagePropertiesDialog::PackagePropertiesDialog(TransferItem *package, QWidget *parent) :
    QDialog(parent),
    m_package(package),
    m_categoryModel(new CategorySelectionModel(this)),
    m_priorityModel(new TransferItemPriorityModel(this)),
    m_scrollArea(new QScrollArea(this)),
    m_container(new QWidget(m_scrollArea)),
    m_nameLabel(new QLabel(m_container)),
    m_statusLabel(new QLabel(m_container)),
    m_subfolderCheckBox(new QCheckBox(tr("Create subfolder"), m_container)),
    m_categorySelector(new ValueSelector(tr("Category"), m_container)),
    m_prioritySelector(new ValueSelector(tr("Priority"), m_container)),
    m_progressBar(new QProgressBar(m_container)),
    m_vbox(new QVBoxLayout(m_container)),
    m_layout(new QHBoxLayout(this))
{
    setWindowTitle(tr("Package properties"));
    setMinimumHeight(360);

    m_scrollArea->setWidget(m_container);
    m_scrollArea->setWidgetResizable(true);

    m_nameLabel->setWordWrap(true);

    m_statusLabel->setWordWrap(true);

    m_categorySelector->setModel(m_categoryModel);
    
    m_prioritySelector->setModel(m_priorityModel);

    m_progressBar->setRange(0, 100);

    updateCategory(package);
    updateCreateSubfolder(package);
    updateName(package);
    updatePriority(package);
    updateProgress(package);
    updateStatus(package);

    m_vbox->addWidget(m_nameLabel);
    m_vbox->addWidget(m_subfolderCheckBox);
    m_vbox->addWidget(m_categorySelector);
    m_vbox->addWidget(m_prioritySelector);
    m_vbox->addWidget(m_progressBar);
    m_vbox->addWidget(m_statusLabel);
    m_vbox->setContentsMargins(0, 0, 0, 0);

    m_layout->addWidget(m_scrollArea);

    connect(package, SIGNAL(dataChanged(TransferItem*, int)), this, SLOT(onDataChanged(TransferItem*, int)));
    connect(m_subfolderCheckBox, SIGNAL(clicked(bool)), this, SLOT(setCreateSubfolder(bool)));
    connect(m_categorySelector, SIGNAL(valueChanged(QVariant)), this, SLOT(setCategory(QVariant)));
    connect(m_prioritySelector, SIGNAL(valueChanged(QVariant)), this, SLOT(setPriority(QVariant)));
}
/// class HTTP2PriorityQueue
void
HTTP2PriorityQueue::addOrUpdatePriorityNode(HTTPCodec::StreamID id,
                                            http2::PriorityUpdate pri) {
  auto handle = find(id);
  if (handle) {
    // already added
    CHECK(handle->getTransaction() == nullptr);
    updatePriority(handle, pri);
  } else {
    // brand new
    addTransaction(id, pri, nullptr, false /* not permanent */);
  }
}
TEST_F(QueueTest, UpdateParentDescendantExcl) {
  buildSimpleTree();

  updatePriority(1, {5, true, 7});
  dump();

  EXPECT_EQ(nodes_, IDList({{5, 100}, {1, 100}, {3, 20}, {7, 40}, {9, 40}}));
  nextEgress();
  EXPECT_EQ(nodes_, IDList({{5, 100}}));
  signalEgress(5, false);
  signalEgress(1, false);
  nextEgress();
  EXPECT_EQ(nodes_, IDList({{7, 40}, {9, 40}, {3, 20}}));
}
TEST_F(QueueTest, UpdateParentSiblingExcl) {
  buildSimpleTree();

  updatePriority(7, {5, true, 3});
  dump();

  EXPECT_EQ(nodes_, IDList({{1, 100}, {3, 50}, {5, 50},
                              {7, 100}, {9, 100}}));
  signalEgress(1, false);
  signalEgress(3, false);
  signalEgress(5, false);
  nextEgress();
  EXPECT_EQ(nodes_, IDList({{7, 100}}));
}
TEST_F(QueueTest, UpdateParentSibling) {
  buildSimpleTree();

  updatePriority(5, {3, false, 3});
  dump();

  EXPECT_EQ(nodes_, IDList({{1, 100}, {3, 33}, {5, 100},
                               {9, 100}, {7, 66}}));
  signalEgress(1, false);
  nextEgress();
  EXPECT_EQ(nodes_, IDList({{7, 66}, {3, 33}}));

  // Clear 5's egress (so it is only in the tree because 9 has egress) and move
  // it back.  Hit's a slightly different code path in reparent
  signalEgress(5, false);
  updatePriority(5, {1, false, 3});
  dump();

  EXPECT_EQ(nodes_, IDList({{1, 100}, {3, 25}, {7, 50}, {5, 25}, {9, 100}}));

  nextEgress();
  EXPECT_EQ(nodes_, IDList({{7, 50}, {3, 25}, {9, 25}}));
}
HTTP2PriorityQueue::Handle
HTTP2PriorityQueue::addTransaction(HTTPCodec::StreamID id,
                                   http2::PriorityUpdate pri,
                                   HTTPTransaction *txn,
                                   bool permanent,
                                   uint64_t* depth) {
  CHECK_NE(id, 0);
  CHECK_NE(id, pri.streamDependency) << "Tried to create a loop in the tree";
  CHECK(!txn || !permanent);
  Node *existingNode = find(id);
  if (existingNode) {
    CHECK(txn);
    CHECK(!permanent);
    existingNode->convertVirtualNode(txn);
    updatePriority(existingNode, pri);
    return existingNode;
  }
  if (!txn) {
    if (numVirtualNodes_ >= maxVirtualNodes_) {
      return nullptr;
    }
    numVirtualNodes_++;
  }

  Node* parent = &root_;
  if (depth) {
    *depth = 0;
  }
  if (pri.streamDependency != 0) {
    Node* dep = find(pri.streamDependency, depth);
    if (dep == nullptr) {
      // specified a missing parent (timed out an idle node)?
      VLOG(4) << "assigning default priority to txn=" << id;
    } else {
      parent = dep;
    }
  }
  VLOG(4) << "Adding id=" << id << " with parent=" << parent->getID() <<
    " and weight=" << ((uint16_t)pri.weight + 1);
  auto node = folly::make_unique<Node>(*this, parent, id, pri.weight, txn);
  if (permanent) {
    node->setPermanent();
  } else if (!txn) {
    scheduleNodeExpiration(node.get());
  }
  auto result = parent->emplaceNode(std::move(node), pri.exclusive);
  pendingWeightChange_ = true;
  return result;
}
Beispiel #20
0
/*
 * Append the name and priority to strings to be used in vim menu commands.
 */
    void
workshop_submenu_begin(
	char		*label)
{
#ifdef WSDEBUG_TRACE
    if (ws_debug  && ws_dlevel & WS_TRACE
	    && strncmp(curMenuName, "ToolBar", 7) != 0)
	wstrace("workshop_submenu_begin(%s)\n", label);
#endif

    strcat(curMenuName, ".");
    strcat(curMenuName, fixup(label));

    updatePriority(True);
}
int thread_join(thread_t identity, void **retval){

#ifdef O_PREEMPTION
  interruptsOff();
#endif
  //thread attendu
  thread* waited = retrouverLeThread(identity);

  //thread attendant
  thread* waiting = getRunningThread();

#ifdef O_PRIORITE
  updatePriority(waiting);
#endif  

  //si le thread à attendre n'existe pas
  if(!waited){
    return -1;
  }

  //si le thread à attendre attend aussi un autre thread
  if(waited->state == STATUS_STOP){
    return -1;
  }
  
  //on recupere l'adresse de la valeur de retour
  waited->adresseValRetour = retval;
  
  //on stocke dans la structure le thread qui attend
  waited->est_attendu = TRUE;
  waited->threadAttendant = waiting;
  
  //Si le thread a déjà terminé, on nettoie et on quitte
  if(waited->state == STATUS_FINISH){
    nettoyage_thread_termine(waited);
    return 0;
  }

  //sinon on lance le thread
  waiting->state = STATUS_STOP;
  addInFifo(waiting);
  setRunningThread(waited);

  swapcontext(waiting->context, waited->context);
  return 0;
}
Beispiel #22
0
void HTouchEnabledLayerColor::presentNode(CCNode *node) {
    if (node->getParent() == this) return;
    
    HBakNodeInfo *info = HBakNodeInfo::create(node, node->getParent(), node->getPosition());
    bakAllPriorities(info, node);
    m_pBakNodeList->addObject(info);
    
    CCPoint pos = node->getPosition();
    pos = node->getParent()->convertToWorldSpace(pos);
    pos = convertToNodeSpace(pos);
    node->retain();
    node->removeFromParentAndCleanup(false);
    addChild(node);
//    pos = node->convertToNodeSpace(pos);
    node->setPosition(pos);
    node->release();
    updatePriority(node);
}
int thread_create(thread_t*t,void*(*func)(void *),void*arg){
#ifdef O_PREEMPTION
  interruptsOff();
#endif
  //si le main n'est pas un thread, il le devient sinon
  if(MAIN_IS_THREAD == FALSE && mainBecomesThread()==-1)
    return -1;

  //on cree le context du thread
  ucontext_t *uc = createContext((void (*) (void))func,arg);
  if(uc == NULL)
    return -1;

  //on cree le thread
  *t = getNextTID();
  thread *newth = newThread(*t, STATUS_READY, uc);

  //on met à jour la rélation thread pere et thread fils
  thread* pere = getRunningThread();
  pere->is_father = TRUE;
  newth->father = pere;
  newth->context->uc_link = pere->context;
  addInFifo(pere);

#ifdef O_PRIORITE
  updatePriority(pere);
#endif  

  //on lance le nouveau thread cree
  setRunningThread(newth);

#ifdef O_PREEMPTION
  interruptsOn();
#endif
  swapcontext(pere->context, newth->context);
  return 0;
}
void ComputationDependencyGraph::update(
			std::set<ComputationId>& outLocalComputationsWithChangedPriorities,
			std::set<ComputationId>& outAllComputationsWithChangedPriorities
			)
	{
	outLocalComputationsWithChangedPriorities.clear();
	outAllComputationsWithChangedPriorities.clear();

	long passesWhereSetIsStable = 0;

	while (mDirtyPriorities.size())
		{
		std::set<ComputationId> newDirty;

		std::set<ComputationId> toCheck = mDirtyPriorities;

		while(toCheck.size())
			{
			ComputationId id = *toCheck.begin();
			toCheck.erase(id);
			lassert(id.isRoot());

			ComputationPriority newPriority = computePriorityFor(id);

			if (newPriority != mAllPriorities[id])
				{
				mAllPriorities[id] = newPriority;

				const std::set<ComputationId>& children = mRootToRootDependencies.getValues(id);
	
				newDirty.insert(id);

				for (auto it = children.begin(); it != children.end(); ++it)
					{
					if (newDirty.find(*it) == newDirty.end())
						{
						newDirty.insert(*it);
						toCheck.insert(*it);
						}
					}

				outAllComputationsWithChangedPriorities.insert(id);

				if (mLocalComputations.find(id) != mLocalComputations.end())
					outLocalComputationsWithChangedPriorities.insert(id);
				}
			}

		if (mDirtyPriorities != newDirty)
			{
			mDirtyPriorities = newDirty;
			passesWhereSetIsStable = 0;
			}
		else 
			{
			passesWhereSetIsStable++;
			
			if (passesWhereSetIsStable > 1)
				{
				// this subset is circular
				for (auto id: mDirtyPriorities)
					updatePriority(
						id,
						mAllPriorities[id].makeCircular(),
						outLocalComputationsWithChangedPriorities,
						outAllComputationsWithChangedPriorities
						);

				mDirtyPriorities.clear();
				}
			}
		}

	std::set<ComputationId> toCheck = outAllComputationsWithChangedPriorities;

	//then check that all splits are correctly accounted for
	for (auto rootId: toCheck)
		for (auto split: mRootToSplitDependencies.getValues(rootId))
			mDirtySplitPriorities.insert(split);

	for (auto split: mDirtySplitPriorities)
		{
		ComputationPriority newPri = computePriorityFor(split);

		if (mAllPriorities[split] != newPri)
			{
			mAllPriorities[split] = newPri;
			outAllComputationsWithChangedPriorities.insert(split);
			if (mLocalComputations.find(split) != mLocalComputations.end())
				outLocalComputationsWithChangedPriorities.insert(split);
			}
		}

	mDirtySplitPriorities.clear();
	}
Beispiel #25
0
/*ARGSUSED*/
    void
workshop_menu_item(
	char		*label,
	char		*verb,
	char		*accelerator,
	char		*acceleratorText,
	char		*name,
	char		*filepos,
	char		*sensitive)
{
    char		 cbuf[BUFSIZ];
    char		 namebuf[BUFSIZ];
    char		 accText[BUFSIZ];

#ifdef WSDEBUG_TRACE
    if (WSDLEVEL(WS_TRACE_VERBOSE)
	    && strncmp(curMenuName, "ToolBar", 7) != 0)
    {
	if (ws_dlevel & WS_TRACE_VERBOSE)
	    wsdebug("workshop_menu_item(\n"
		    "\tlabel = \"%s\",\n"
		    "\tverb = %s,\n"
		    "\taccelerator = %s,\n"
		    "\tacceleratorText = \"%s\",\n"
		    "\tname = %s,\n"
		    "\tfilepos = %s,\n"
		    "\tsensitive = %s)\n",
		    label && *label ? label : "<None>",
		    verb && *verb ? verb : "<None>",
		    accelerator && *accelerator ?
		    accelerator : "<None>",
		    acceleratorText && *acceleratorText ?
		    acceleratorText : "<None>",
		    name && *name ? name : "<None>",
		    filepos && *filepos ? filepos : "<None>",
		    sensitive);
	else if (ws_dlevel & WS_TRACE)
	    wstrace("workshop_menu_item(\"%s\", %s)\n",
		    label && *label ? label : "<None>",
		    verb && *verb ? verb : "<None>", sensitive);
    }
#endif
#ifdef WSDEBUG_SENSE
    if (ws_debug)
	wstrace("menu:   %-21.20s%-21.20s(%s)\n", label, verb,
		*sensitive == '1' ? "Sensitive" : "Insensitive");
#endif

    if (acceleratorText != NULL)
	sprintf(accText, "<Tab>%s", acceleratorText);
    else
	accText[0] = NUL;
    updatePriority(False);
    sprintf(namebuf, "%s.%s", curMenuName, fixup(label));
    sprintf(cbuf, "amenu %s %s%s\t:wsverb %s<CR>",
	    curMenuPriority, namebuf, accText, verb);

    coloncmd(cbuf, TRUE);
    addMenu(namebuf, fixAccelText(acceleratorText), verb);

    if (*sensitive == '0')
    {
	sprintf(cbuf, "amenu disable %s", namebuf);
	coloncmd(cbuf, TRUE);
    }
}