### Home Classes Methods

### In Files

- lib/termtter/task_manager.rb

### Parent

Object

### Methods

- ::new
- #add_task
- #delete_task
- #get_task
- #invoke_and_wait
- #invoke_later
- #kill
- #pause
- #resume
- #run
- #step

### Files

- ChangeLog
- README.rdoc

### Class/Module Index

Quicksearch

- Termtter
- Termtter::API
- Termtter::ActiveRubytter
- Termtter::Client
- Termtter::Client::DirectMessage
- Termtter::Client::Jakigan
- Termtter::Client::SearchEvent
- Termtter::Client::UserSearchEvent
- Termtter::Command
- Termtter::CommandCanceled
- Termtter::CommandLine
- Termtter::CommandNotFound
- Termtter::Config
- Termtter::ConfigSetup
- Termtter::Crypt
- Termtter::English
- Termtter::Event
- Termtter::HTTPpool
- Termtter::Hook
- Termtter::HookCanceled
- Termtter::Hookable
- Termtter::JSONError
- Termtter::MemoryCache
- Termtter::MemoryCache::MemCacheMock
- Termtter::OptParser
- Termtter::Plugin
- Termtter::Plugin::Screen
- Termtter::Plugins
- Termtter::Plugins::Haml
- Termtter::Plugins::ListSwitch
- Termtter::RubytterProxy
- Termtter::RubytterProxy::FrequentAccessError
- Termtter::RubytterProxy::LimitManager
- Termtter::Status
- Termtter::StdOut
- Termtter::Storage
- Termtter::Storage::SQLite3
- Termtter::Storage::Status
- Termtter::Task
- Termtter::TaskManager
- Termtter::TypableIdGenerator
- Termtter::UserStreamReceiver
- Yharian
- Yharian::Alex
- Yharian::Jenifer
- Yharian::Remark
- Yharian::Speaker
- Yharian::Vicki
- Yharian::Yhara
- HatenaKeywordHaiku
- HatenaKeywordHaiku::Word
- OAuth
- OAuth::AccessToken
- Readline
- Readline::LIBREADLINE
- AAMaker
- Array
- BrowserNotFound
- Growl
- IRB
- Object
- Status
- String
- Symbol
- TermColor
- TermtterIrcGateway
- User

No matching classes.

# Termtter::TaskManager

### Public Class Methods

new(interval = 1) click to toggle source

    # File lib/termtter/task_manager.rb, line 5
    def initialize(interval = 1)
      @interval = interval
      @tasks = {}
      @work = true
      @mutex = Mutex.new
      @pause = false
    end

### Public Instance Methods

add_task(args = {}, &block) click to toggle source

    # File lib/termtter/task_manager.rb, line 54
    def add_task(args = {}, &block)
      synchronize do
        task = Task.new(args, &block)
        @tasks[task.name || task.object_id] = task
      end
    end

delete_task(key) click to toggle source

    # File lib/termtter/task_manager.rb, line 67
    def delete_task(key)
      synchronize do
        @tasks.delete(key)
      end
    end

get_task(key) click to toggle source

    # File lib/termtter/task_manager.rb, line 61
    def get_task(key)
      synchronize do
        @tasks[key]
      end
    end

invoke_and_wait(&block) click to toggle source

    # File lib/termtter/task_manager.rb, line 48
    def invoke_and_wait(&block)
      synchronize do
        yield
      end
    end

invoke_later() click to toggle source

    # File lib/termtter/task_manager.rb, line 42
    def invoke_later
      Thread.new do
        invoke_and_wait { yield }
      end
    end

kill() click to toggle source

    # File lib/termtter/task_manager.rb, line 21
    def kill
      @work = false
    end

pause() click to toggle source

    # File lib/termtter/task_manager.rb, line 13
    def pause
      @pause = true
    end

resume() click to toggle source

    # File lib/termtter/task_manager.rb, line 17
    def resume
      @pause = false
    end

run() click to toggle source

    # File lib/termtter/task_manager.rb, line 25
    def run
      Thread.new do
        while @work
          step unless @pause
          sleep @interval
        end
      end
    end

step() click to toggle source

    # File lib/termtter/task_manager.rb, line 34
    def step
      pull_due_tasks.each do |task|
        invoke_and_wait do
          task.execute
        end
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.