Пример #1
0
static void MainL()
{
  log_clear(PRIMARY_LOG_FILENAME);
  log_text(PRIMARY_LOG_FILENAME, "initializing");
  logg("value is %d", 555);
  log_ctx(PRIMARY_LOG_FILENAME, "context test");

  // Note that if our program does not run for at least five seconds
  // or so, the S60 auto launch mechanism will consider that an error,
  // and this may result in some error dialog popping up. We use
  // WaitWhile() to avoid that sort of thing where an intrusive error
  // report is not called for. Calling WaitWhile will hopefully also
  // ensure that the system is somewhat up and running even right after
  // boot, so that there are no problems with querying the installed
  // apps information or anything like that.
  WaitWhile();

  RFs fs;
  User::LeaveIfError(fs.Connect());
  CleanupClosePushL(fs);

  TBool magicFileExists = MagicFileExists(fs);
  if (!magicFileExists) {
    TBool isAppInstalled = IsAppInstalledL();
    if (isAppInstalled) {
      MainLoopL();
    } else {
      logt("program to launch not installed");
    }
  } else {
    logt("magic file exists");
  }

  CleanupStack::PopAndDestroy(); // fs
}
Пример #2
0
void Buffer::Put(int element)
{
	this->Lock();
	// the following statement releases the lock if the process can't proceed
	WaitWhile(counter>=CAPACITY);
	
	this->counter++;
	this->elements[this->putPosition] = element;
	this->putPosition = (this->putPosition+1) % CAPACITY;
	std::cout << "Producer: Element " << element << " added\n";
	
	this->Unlock();
}
Пример #3
0
int Buffer::Get() 
{
	int output;

	this->Lock();
	WaitWhile(counter<=0);

	this->counter--;
	output = this->elements[this->getPosition];
	this->getPosition = (this->getPosition+1) % CAPACITY;
	std::cout << "Consumer: Element " << output << " taken\n";
	
	this->Unlock();

	return output;
}