Beispiel #1
0
bool Mutex::tryLock(honey::MonoClock::TimePoint time)
{
    assert(_tryLock, "Unsupported Op: not a timed mutex");
    if (tryLock()) return true;

    UniqueLock<honey::Mutex> lock(*_tryLock);
    bool res;
    ++_tryWaitCount;
    while ((res = tryLock()) == false && _tryCond->wait(lock, time));
    --_tryWaitCount;
    return res;
}
uint32_t audio_track_cblk_t::framesReady(bool isOut)
{
    uint32_t u = user;
    uint32_t s = server;

    if (isOut) {
        if (u < loopEnd) {
            return u - s;
        } else {
            // do not block on mutex shared with client on AudioFlinger side
            if (!tryLock()) {
                ALOGW("framesReady() could not lock cblk");
                return 0;
            }
            uint32_t frames = UINT_MAX;
            if (loopCount >= 0) {
                frames = (loopEnd - loopStart)*loopCount + u - s;
            }
            lock.unlock();
            return frames;
        }
    } else {
        return s - u;
    }
}
inline extern void acquire_lock(Lock * lock_ptr, int threadId, Counter * counter)
{
  int val;
  bool got_lock = false;
  while(!got_lock) {
   
#ifdef DEBUG
    printf("thread %d stuck in acquire_lock loop on lock %x, counter = %d\n", 
 	   threadId, lock_ptr, counter->count_var);
#endif
    
    // Test
    while(lock_ptr->lock_var != 0) {
      // Nothing
#ifdef DEBUG
      printf("thread %d stuck in test loop on lock %x, counter = %d\n", threadId, lock_ptr, counter->count_var);
#endif
    }
    
    // Atomic Test & Set
    val = tryLock((void *) &(lock_ptr->lock_var));
    
    // got lock
    if(val == 0){
      got_lock = true;
#ifdef DEBUG
      printf("Got the lock, and lock_var is %x\n", lock_ptr->lock_var);
#endif

    }
  }
}
Beispiel #4
0
status_t AudioPolicyService::dump(int fd, const Vector<String16>& args)
{
    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
        dumpPermissionDenial(fd);
    } else {
        bool locked = tryLock(mLock);
        if (!locked) {
            String8 result(kDeadlockedString);
            write(fd, result.string(), result.size());
        }

        dumpInternals(fd);
        if (mAudioCommandThread != NULL) {
            mAudioCommandThread->dump(fd);
        }
        if (mTonePlaybackThread != NULL) {
            mTonePlaybackThread->dump(fd);
        }

        if (mpPolicyManager) {
            mpPolicyManager->dump(fd);
        }

        if (locked) mLock.unlock();
    }
    return NO_ERROR;
}
void AudioContext::handlePostRenderTasks()
{
    ASSERT(isAudioThread());
 
    // Must use a tryLock() here too.  Don't worry, the lock will very rarely be contended and this method is called frequently.
    // The worst that can happen is that there will be some nodes which will take slightly longer than usual to be deleted or removed
    // from the render graph (in which case they'll render silence).
    bool mustReleaseLock;
    if (tryLock(mustReleaseLock)) {
        // Take care of finishing any derefs where the tryLock() failed previously.
        handleDeferredFinishDerefs();

        // Dynamically clean up nodes which are no longer needed.
        derefFinishedSourceNodes();

        // Finally actually delete.
        deleteMarkedNodes();

        // Fixup the state of any dirty AudioNodeInputs and AudioNodeOutputs.
        handleDirtyAudioNodeInputs();
        handleDirtyAudioNodeOutputs();
        
        if (mustReleaseLock)
            unlock();
    }
}
status_t AudioPolicyService::dump(int fd, const Vector<String16>& args)
{
    if (!dumpAllowed()) {
        dumpPermissionDenial(fd);
    } else {
        bool locked = tryLock(mLock);
        if (!locked) {
            String8 result(kDeadlockedString);
            write(fd, result.string(), result.size());
        }

        dumpInternals(fd);
        if (mAudioCommandThread != 0) {
            mAudioCommandThread->dump(fd);
        }
        if (mTonePlaybackThread != 0) {
            mTonePlaybackThread->dump(fd);
        }

        if (mpAudioPolicy) {
            mpAudioPolicy->dump(mpAudioPolicy, fd);
        }

        if (locked) mLock.unlock();
    }
    return NO_ERROR;
}
status_t AudioPolicyService::AudioCommandThread::dump(int fd)
{
    const size_t SIZE = 256;
    char buffer[SIZE];
    String8 result;

    snprintf(buffer, SIZE, "AudioCommandThread %p Dump\n", this);
    result.append(buffer);
    write(fd, result.string(), result.size());

    bool locked = tryLock(mLock);
    if (!locked) {
        String8 result2(kCmdDeadlockedString);
        write(fd, result2.string(), result2.size());
    }

    snprintf(buffer, SIZE, "- Commands:\n");
    result = String8(buffer);
    result.append("   Command Time        Wait pParam\n");
    for (int i = 0; i < (int)mAudioCommands.size(); i++) {
        mAudioCommands[i]->dump(buffer, SIZE);
        result.append(buffer);
    }
    result.append("  Last Command\n");
    mLastCommand.dump(buffer, SIZE);
    result.append(buffer);

    write(fd, result.string(), result.size());

    if (locked) mLock.unlock();

    return NO_ERROR;
}
Beispiel #8
0
void CDIODestroyTimer::setInstance( CdIo_t *cdio, const QString &device, unsigned discID )
{
	if ( tryLock() )
		emit startTimerSig( cdio, device, discID );
	else
		cdio_destroy( cdio );
}
Beispiel #9
0
Galois::Runtime::LockManagerBase::AcquireStatus
Galois::Runtime::LockManagerBase::tryAcquire(Galois::Runtime::Lockable* lockable) 
{
  assert(lockable);
  // XXX(ddn): Hand inlining this code makes a difference on 
  // delaunaytriangulation (GCC 4.7.2)
#if 0
  if (tryLock(lockable)) {
    assert(!getOwner(lockable));
    ownByForce(lockable);
    return NEW_OWNER;
#else
  if (lockable->owner.try_lock()) {
    lockable->owner.setValue(this);
    return NEW_OWNER;
#endif
  } else if (getOwner(lockable) == this) {
    return ALREADY_OWNER;
  }
  return FAIL;
}

void Galois::Runtime::SimpleRuntimeContext::acquire(Galois::Runtime::Lockable* lockable) {
  AcquireStatus i;
  if (customAcquire) {
    subAcquire(lockable);
  } else if ((i = tryAcquire(lockable)) != AcquireStatus::FAIL) {
    if (i == AcquireStatus::NEW_OWNER) {
      addToNhood(lockable);
    }
  } else {
    Galois::Runtime::signalConflict(lockable);
  }
}
Beispiel #10
0
void AudioContext::handlePostRenderTasks()
{
    ASSERT(isAudioThread());

    // Must use a tryLock() here too. Don't worry, the lock will very rarely be contended and this method is called frequently.
    // The worst that can happen is that there will be some nodes which will take slightly longer than usual to be deleted or removed
    // from the render graph (in which case they'll render silence).
    bool mustReleaseLock;
    if (tryLock(mustReleaseLock)) {
        // Take care of finishing any derefs where the tryLock() failed previously.
        handleDeferredFinishDerefs();

        // Dynamically clean up nodes which are no longer needed.
        derefFinishedSourceNodes();

        // Don't delete in the real-time thread. Let the main thread do it.
        // Ref-counted objects held by certain AudioNodes may not be thread-safe.
        scheduleNodeDeletion();

        // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutputs.
        handleDirtyAudioSummingJunctions();
        handleDirtyAudioNodeOutputs();

        updateAutomaticPullNodes();

        if (mustReleaseLock)
            unlock();
    }
}
Beispiel #11
0
bool gcore::Mutex::isLocked() {
  if (tryLock()) {
    unlock();
    return false;
  }
  return true;
}
Beispiel #12
0
void btSpinMutex::lock()
{
    // note: this lock does not sleep the thread
    while (! tryLock())
    {
        // spin
    }
}
Beispiel #13
0
bool TimedMutex::tryLock(honey::MonoClock::TimePoint time)
{
    ConditionLock::Scoped _(_tryCond);
    bool res;
    ++_tryWaitCount;
    while (!(res = tryLock()) && _tryCond.wait(time));
    --_tryWaitCount;
    return res;
}
bool CountingMutex::tryEnter()		
{
    if (!tryLock())
        return false;
    mCount++;
    secdebug("cmutex", "%p up to %d (was try)", this, mCount);
    unlock();
    return true;
}
Beispiel #15
0
bool LLMutexBase::isLocked()
{
    if (!tryLock())
    {
        return true;
    }
    apr_thread_mutex_unlock(mAPRMutexp);
    return false;
}
bool audio_track_cblk_t::stepServer(size_t stepCount, size_t frameCount, bool isOut)
{
    ALOGV("stepserver %08x %08x %d", user, server, stepCount);

    if (!tryLock()) {
        ALOGW("stepServer() could not lock cblk");
        return false;
    }

    uint32_t s = server;
    bool flushed = (s == user);

    s += stepCount;
    if (isOut) {
        // Mark that we have read the first buffer so that next time stepUser() is called
        // we switch to normal obtainBuffer() timeout period
        if (bufferTimeoutMs == MAX_STARTUP_TIMEOUT_MS) {
            bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS - 1;
        }
        // It is possible that we receive a flush()
        // while the mixer is processing a block: in this case,
        // stepServer() is called After the flush() has reset u & s and
        // we have s > u
        if (flushed) {
            ALOGW("stepServer occurred after track reset");
            s = user;
        }
    }

    if (s >= loopEnd) {
        ALOGW_IF(s > loopEnd, "stepServer: s %u > loopEnd %u", s, loopEnd);
        s = loopStart;
        if (--loopCount == 0) {
            loopEnd = UINT_MAX;
            loopStart = UINT_MAX;
        }
    }

    if (s >= frameCount) {
        // common case, server didn't just wrap
        if (s - frameCount >= serverBase ) {
            serverBase += frameCount;
        }
    } else if (s >= serverBase + frameCount) {
        // server just wrapped
        serverBase += frameCount;
    }

    server = s;

    if (!(flags & CBLK_INVALID)) {
        cv.signal();
    }
    lock.unlock();
    return true;
}
status_t CameraService::dump(int fd, const Vector<String16>& args) {
    static const char* kDeadlockedString = "CameraService may be deadlocked\n";

    const size_t SIZE = 256;
    char buffer[SIZE];
    String8 result;
    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
        snprintf(buffer, SIZE, "Permission Denial: "
                "can't dump CameraService from pid=%d, uid=%d\n",
                getCallingPid(),
                getCallingUid());
        result.append(buffer);
        write(fd, result.string(), result.size());
    } else {
        bool locked = tryLock(mServiceLock);
        // failed to lock - CameraService is probably deadlocked
        if (!locked) {
            String8 result(kDeadlockedString);
            write(fd, result.string(), result.size());
        }

        bool hasClient = false;
        for (int i = 0; i < mNumberOfCameras; i++) {
            sp<Client> client = mClient[i].promote();
            if (client == 0) continue;
            hasClient = true;
            sprintf(buffer, "Client[%d] (%p) PID: %d\n",
                    i,
                    client->getCameraClient()->asBinder().get(),
                    client->mClientPid);
            result.append(buffer);
            write(fd, result.string(), result.size());
            client->mHardware->dump(fd, args);
        }
        if (!hasClient) {
            result.append("No camera client yet.\n");
            write(fd, result.string(), result.size());
        }

        if (locked) mServiceLock.unlock();

        // change logging level
        int n = args.size();
        for (int i = 0; i + 1 < n; i++) {
            if (args[i] == String16("-v")) {
                String8 levelStr(args[i+1]);
                int level = atoi(levelStr.string());
                sprintf(buffer, "Set Log Level to %d", level);
                result.append(buffer);
                setLogLevel(level);
            }
        }
    }
    return NO_ERROR;
}
Beispiel #18
0
void Mutex::lock()
{
    Timer timer;
    while (!tryLock()) {
        usleep(10000);
        if (timer.elapsed() >= 10000) {
            error("Couldn't acquire lock in 10 seconds\n%s", RTags::backtrace().constData());
            timer.restart();
        }
    }
}
Beispiel #19
0
void ScopeGUI::setAudioBuffer(Buffer const& audioBufferToUse, const double offset, const int fftSizeOfSource) throw()
{	
	offsetSamples = offset; // this will be a time offset in samples or the first bin for an FFT
	
	if(fftSizeOfSource > 0)
		fftSize = fftSizeOfSource;
	
	if(tryLock() == true)
	{
		if((smoothingBuffer.size() > 0) && 
		   (audioBuffer.size() == audioBufferToUse.size()) &&
		   (audioBuffer.getNumChannels() == audioBufferToUse.getNumChannels())
		) {
			// smoothingBuffer should be interpolation coeffs for each channel
			// so Buffer(0.25, 1.0) should smooth even channels but not odd channels
			
			Buffer newBuffer;
			
			for(int i = 0; i < audioBuffer.getNumChannels(); i++)
			{
				const float coeff = smoothingBuffer.wrapAt(i);
				
				if(coeff > -1.f && coeff < 1.f)
				{
					newBuffer <<= audioBuffer.getChannel(i).blend(audioBufferToUse.getChannel(i), coeff);
				}
				else
				{
					newBuffer <<= audioBufferToUse.getChannel(i);
				}
			}
			
			audioBuffer = newBuffer;
		}
		else if((audioBuffer.size() == audioBufferToUse.size()) && 
				(audioBuffer.getNumChannels() == audioBufferToUse.getNumChannels()))
		{
			audioBuffer.copyFrom(audioBufferToUse);
		}
		else
		{
			audioBuffer = audioBufferToUse.copy();
		}
		
		initBuffers();
		unlock();
		
		updateGUI();
	}
}
Beispiel #20
0
/*!
    Destroys the mutex.

    \warning Destroying a locked mutex may result in undefined behavior.
*/
QMutex::~QMutex()
{
    QMutexData *d = d_ptr.load();
    if (quintptr(d) > 0x3 && d->recursive) {
        delete static_cast<QRecursiveMutexPrivate *>(d);
    } else if (d) {
#ifndef Q_OS_LINUX
        if (d != dummyLocked() && static_cast<QMutexPrivate *>(d)->possiblyUnlocked.load()
            && tryLock()) {
            unlock();
            return;
        }
#endif
        qWarning("QMutex: destroying locked mutex");
    }
}
Beispiel #21
0
void AudioContext::handlePreRenderTasks()
{
    ASSERT(isAudioThread());
 
    // At the beginning of every render quantum, try to update the internal rendering graph state (from main thread changes).
    // It's OK if the tryLock() fails, we'll just take slightly longer to pick up the changes.
    bool mustReleaseLock;
    if (tryLock(mustReleaseLock)) {
        // Fixup the state of any dirty AudioNodeInputs and AudioNodeOutputs.
        handleDirtyAudioNodeInputs();
        handleDirtyAudioNodeOutputs();
        
        if (mustReleaseLock)
            unlock();
    }
}
void AbstractAudioContext::handlePreRenderTasks()
{
    ASSERT(isAudioThread());

    // At the beginning of every render quantum, try to update the internal rendering graph state (from main thread changes).
    // It's OK if the tryLock() fails, we'll just take slightly longer to pick up the changes.
    if (tryLock()) {
        deferredTaskHandler().handleDeferredTasks();

        resolvePromisesForResume();

        // Check to see if source nodes can be stopped because the end time has passed.
        handleStoppableSourceNodes();

        unlock();
    }
}
Beispiel #23
0
      void
      startManeuver(const M* maneuver)
      {
        if (!isActive())
        {
          while (!tryLock())
          {
            Time::Delay::wait(0.5);
          }
        }

        debug("enabling");
        signalProgress(65535, "in progress");

        static_cast<T*>(this)->consume(maneuver);

        if (m_mcs.state == IMC::ManeuverControlState::MCS_EXECUTING)
          requestActivation();
      }
void AbstractAudioContext::handlePostRenderTasks()
{
    ASSERT(isAudioThread());

    // Must use a tryLock() here too.  Don't worry, the lock will very rarely be contended and this method is called frequently.
    // The worst that can happen is that there will be some nodes which will take slightly longer than usual to be deleted or removed
    // from the render graph (in which case they'll render silence).
    if (tryLock()) {
        // Take care of AudioNode tasks where the tryLock() failed previously.
        deferredTaskHandler().breakConnections();

        // Dynamically clean up nodes which are no longer needed.
        releaseFinishedSourceNodes();

        deferredTaskHandler().handleDeferredTasks();
        deferredTaskHandler().requestToDeleteHandlersOnMainThread();

        unlock();
    }
}
Beispiel #25
0
void ScopeGUI::calculateBuffers()
{	
	if(tryLock() == true)
	{
		const int audioBufferSize = audioBuffer.size();
		const int drawBufferSize = getDisplayBufferSize();
		
		if(audioBufferSize > 0 && minDrawBuffer.size() > 0 && maxDrawBuffer.size() > 0)
		{
			minDrawBuffer.clear();
			maxDrawBuffer.clear();
			
			const double drawIndexInc = min(1.0, (double)drawBufferSize / (double)audioBufferSize);
			const double audioIndexInc = min(1.0, (double)audioBufferSize / (double)drawBufferSize);
			
			for(int channel = 0; channel < audioBuffer.getNumChannels(); channel++)
			{		
				if(drawIndexInc < 1.0)
				{
					double drawIndex = 0.0;			
					int previousDrawIndex = -1;
					float minimum = 0.f, maximum = 0.f;
					
					for(int sample = 0; sample < audioBufferSize; sample++, drawIndex += drawIndexInc)
					{
						const int iDrawIndex = (int)drawIndex;
						float value = audioBuffer.getSampleUnchecked(channel, sample);
						if(previousDrawIndex != iDrawIndex)
						{
							if(previousDrawIndex >= 0)
							{
								minDrawBuffer.setSampleUnchecked(channel, previousDrawIndex, minimum);
								maxDrawBuffer.setSampleUnchecked(channel, previousDrawIndex, maximum);
							}
							
							minimum = maximum = value;
							previousDrawIndex = iDrawIndex;
						}
						else
						{
							minimum = min(minimum, value);
							maximum = max(maximum, value);
						}
					}
				}
				else
				{
					double audioIndex = 0.0;
					
					for(int horiz = 0; horiz < drawBufferSize; horiz++, audioIndex += audioIndexInc)
					{
						float value = audioBuffer.getSampleUnchecked(channel, (int)audioIndex);
						minDrawBuffer.setSampleUnchecked(channel, horiz, value);
						maxDrawBuffer.setSampleUnchecked(channel, horiz, value);
					}
				}
				
			}
		}
		
		unlock();
	}
}
bool InstrumentTrack::play( const MidiTime & _start, const fpp_t _frames,
							const f_cnt_t _offset, int _tco_num )
{
	if( ! m_instrument || ! tryLock() )
	{
		return false;
	}
	const float frames_per_tick = Engine::framesPerTick();

	tcoVector tcos;
	::BBTrack * bb_track = NULL;
	if( _tco_num >= 0 )
	{
		TrackContentObject * tco = getTCO( _tco_num );
		tcos.push_back( tco );
		bb_track = BBTrack::findBBTrack( _tco_num );
	}
	else
	{
		getTCOsInRange( tcos, _start, _start + static_cast<int>(
					_frames / frames_per_tick ) );
	}

	// Handle automation: detuning
	for( NotePlayHandleList::Iterator it = m_processHandles.begin();
					it != m_processHandles.end(); ++it )
	{
		( *it )->processMidiTime( _start );
	}

	if ( tcos.size() == 0 )
	{
		unlock();
		return false;
	}

	bool played_a_note = false;	// will be return variable

	for( tcoVector::Iterator it = tcos.begin(); it != tcos.end(); ++it )
	{
		Pattern* p = dynamic_cast<Pattern*>( *it );
		// everything which is not a pattern or muted won't be played
		if( p == NULL || ( *it )->isMuted() )
		{
			continue;
		}
		MidiTime cur_start = _start;
		if( _tco_num < 0 )
		{
			cur_start -= p->startPosition();
		}

		// get all notes from the given pattern...
		const NoteVector & notes = p->notes();
		// ...and set our index to zero
		NoteVector::ConstIterator nit = notes.begin();

		// very effective algorithm for playing notes that are
		// posated within the current sample-frame


		if( cur_start > 0 )
		{
			// skip notes which are posated before start-tact
			while( nit != notes.end() && ( *nit )->pos() < cur_start )
			{
				++nit;
			}
		}

		Note * cur_note;
		while( nit != notes.end() &&
					( cur_note = *nit )->pos() == cur_start )
		{
			if( cur_note->length() != 0 )
			{
				const f_cnt_t note_frames =
					cur_note->length().frames(
							frames_per_tick );

				NotePlayHandle* notePlayHandle = NotePlayHandleManager::acquire( this, _offset, note_frames, *cur_note );
				notePlayHandle->setBBTrack( bb_track );
				// are we playing global song?
				if( _tco_num < 0 )
				{
					// then set song-global offset of pattern in order to
					// properly perform the note detuning
					notePlayHandle->setSongGlobalParentOffset( p->startPosition() );
				}

				Engine::mixer()->addPlayHandle( notePlayHandle );
				played_a_note = true;
			}
			++nit;
		}
	}
	unlock();
	return played_a_note;
}
status_t CameraService::dump(int fd, const Vector<String16>& args) {
    String8 result;
    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
        result.appendFormat("Permission Denial: "
                "can't dump CameraService from pid=%d, uid=%d\n",
                getCallingPid(),
                getCallingUid());
        write(fd, result.string(), result.size());
    } else {
        bool locked = tryLock(mServiceLock);
        // failed to lock - CameraService is probably deadlocked
        if (!locked) {
            result.append("CameraService may be deadlocked\n");
            write(fd, result.string(), result.size());
        }

        bool hasClient = false;
        if (!mModule) {
            result = String8::format("No camera module available!\n");
            write(fd, result.string(), result.size());
            return NO_ERROR;
        }

        result = String8::format("Camera module HAL API version: 0x%x\n",
                mModule->common.hal_api_version);
        result.appendFormat("Camera module API version: 0x%x\n",
                mModule->common.module_api_version);
        result.appendFormat("Camera module name: %s\n",
                mModule->common.name);
        result.appendFormat("Camera module author: %s\n",
                mModule->common.author);
        result.appendFormat("Number of camera devices: %d\n\n", mNumberOfCameras);
        write(fd, result.string(), result.size());
        for (int i = 0; i < mNumberOfCameras; i++) {
            result = String8::format("Camera %d static information:\n", i);
            camera_info info;

            status_t rc = mModule->get_camera_info(i, &info);
            if (rc != OK) {
                result.appendFormat("  Error reading static information!\n");
                write(fd, result.string(), result.size());
            } else {
                result.appendFormat("  Facing: %s\n",
                        info.facing == CAMERA_FACING_BACK ? "BACK" : "FRONT");
                result.appendFormat("  Orientation: %d\n", info.orientation);
                int deviceVersion;
                if (mModule->common.module_api_version <
                        CAMERA_MODULE_API_VERSION_2_0) {
                    deviceVersion = CAMERA_DEVICE_API_VERSION_1_0;
                } else {
                    deviceVersion = info.device_version;
                }
                result.appendFormat("  Device version: 0x%x\n", deviceVersion);
                if (deviceVersion >= CAMERA_DEVICE_API_VERSION_2_0) {
                    result.appendFormat("  Device static metadata:\n");
                    write(fd, result.string(), result.size());
                    dump_indented_camera_metadata(info.static_camera_characteristics,
                            fd, 2, 4);
                } else {
                    write(fd, result.string(), result.size());
                }
            }

            sp<Client> client = mClient[i].promote();
            if (client == 0) {
                result = String8::format("  Device is closed, no client instance\n");
                write(fd, result.string(), result.size());
                continue;
            }
            hasClient = true;
            result = String8::format("  Device is open. Client instance dump:\n");
            write(fd, result.string(), result.size());
            client->dump(fd, args);
        }
        if (!hasClient) {
            result = String8::format("\nNo active camera clients yet.\n");
            write(fd, result.string(), result.size());
        }

        if (locked) mServiceLock.unlock();

        // change logging level
        int n = args.size();
        for (int i = 0; i + 1 < n; i++) {
            String16 verboseOption("-v");
            if (args[i] == verboseOption) {
                String8 levelStr(args[i+1]);
                int level = atoi(levelStr.string());
                result = String8::format("\nSetting log level to %d.\n", level);
                setLogLevel(level);
                write(fd, result.string(), result.size());
            }
        }

    }
    return NO_ERROR;
}
Beispiel #28
0
/*!
    Creates the lock file.

    If another process (or another thread) has created the lock file already,
    this function will block until that process (or thread) releases it.

    Calling this function multiple times on the same lock from the same
    thread without unlocking first is not allowed. This function will
    \e dead-lock when the file is locked recursively.

    Returns \c true if the lock was acquired, false if it could not be acquired
    due to an unrecoverable error, such as no permissions in the parent directory.

    \sa unlock(), tryLock()
*/
bool QLockFile::lock()
{
    return tryLock(-1);
}