示例#1
0
void list_foreach(LIST *list, int (*dothis)(void*))
{
	LIST_ITEM * p;
	
	p = list->top;
	while (p) {
		if (dothis)
			dothis(p->data);
		p = p->next;
	}
}
void *proc2(void *a){
    void * result;
    while(1){
        p2wait=1;
        proc_turn=FIRST;
        while(p1wait && proc_turn==FIRST);
        //cs:
        result=dothis(a);
        p2wait=0;
        return result;
    }
}
void *proc1(void *a){
    void * result;
    while(1){
        p1wait=1;
        proc_turn=SECOND;
        while(p2wait && proc_turn==SECOND);
        //cs:
        result=dothis(a);
        p1wait=0;
        return result;
    }
}
void
withBagItem(nsIPropertyBag* source,
            T* target,
            void (*dothis)(T*,
                           nsIVariant*,
                           nsresult (nsIVariant::*)(nsAString&),
                           const char*),
            const char* name)
{
  nsAutoString property;
  nsCOMPtr<nsIVariant> propValue;

  property.AssignLiteral(name);
  nsresult result = source->GetProperty(property, getter_AddRefs(propValue));
  if ( result == NS_ERROR_FAILURE ) {
    return;
  }
  dothis(target, propValue.get(), &nsIVariant::GetAsAString, name);
}