Class: File

### Home Classes Methods

### In Files

- lib/logging/utils.rb

### Parent

Object

### Methods

- #flock?
- #flock_sh

### Files

- History.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Logging
- Logging::Appender
- Logging::Appenders
- Logging::Appenders::Buffering
- Logging::Appenders::Email
- Logging::Appenders::File
- Logging::Appenders::Growl
- Logging::Appenders::IO
- Logging::Appenders::RollingFile
- Logging::Appenders::Stderr
- Logging::Appenders::Stdout
- Logging::Appenders::StringIo
- Logging::Appenders::Syslog
- Logging::ColorScheme
- Logging::Config
- Logging::Config::Configurator
- Logging::Config::Configurator::DSL
- Logging::Config::Configurator::Error
- Logging::Config::Configurator::TopLevelDSL
- Logging::Config::YamlConfigurator
- Logging::Config::YamlConfigurator::Error
- Logging::Layout
- Logging::Layouts
- Logging::Layouts::Basic
- Logging::Layouts::Parseable
- Logging::Layouts::Pattern
- Logging::Logger
- Logging::MappedDiagnosticContext
- Logging::NestedDiagnosticContext
- Logging::Proxy
- Logging::RailsCompat
- Logging::Repository
- Logging::Repository::Singleton
- Logging::RootLogger
- Logging::Stats
- Logging::Stats::Sampler
- Logging::Stats::Tracker
- RSpec
- RSpec::Core
- RSpec::Core::Configuration
- RSpec::LoggingHelper
- RSpec::LoggingHelper
- Spec
- Spec::Runner
- Spec::Runner::Configuration
- Object
- Object::LoggingHelper
- File
- FileUtils
- Hash
- Kernel
- Module
- ReentrantMutex
- String

No matching classes.

# File

### Public Instance Methods

flock?() click to toggle source

Returns `true` if another process holds an exclusive lock on the file. Returns `false` if this is not the case.

If a `block` of code is passed to this method, it will be run iff this process can obtain an exclusive lock on the file. The block will be run while this lock is held, and the exclusive lock will be released when the method returns.

The exclusive lock is requested in a non-blocking mode. This method will return immediately (and the block will not be executed) if an exclusive lock cannot be obtained.

    # File lib/logging/utils.rb, line 145
    def flock?
      status = flock(LOCK_EX|LOCK_NB)
      case status
      when false; true
      when 0; block_given? ? yield : false
      else
        raise SystemCallError, "flock failed with status: #{status}"
      end
    ensure
      flock LOCK_UN
    end

flock_sh() click to toggle source

Execute a `block` in the context of a shared lock on this file. A shared lock will be obtained on the file, the block executed, and the lock released.

    # File lib/logging/utils.rb, line 161
    def flock_sh
      flock LOCK_SH
      yield
    ensure
      flock LOCK_UN
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.