Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Updated the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
flippingbits committed Dec 4, 2010
1 parent a5ee8b2 commit 9bd1aa7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,32 @@ and require it

require "titan"

Creating a new daemon thread using Titan is pretty easy:
Creating a new daemon thread using Titan is pretty easy. First, you've create a new Titan::Thread object and then call its #run method:

Titan::Thread.new do
thread = Titan::Thread.new do
# here comes the programm
sleep(15)
puts "I'm awake!"
end
thread.run

Furthermore you can pass an id to each created thread that can be used for identification in the future:

Titan::Thread.new(:id => "my_new_thread") do
sleep(15)
puts "I'm awake!"
end
end.run

It's also possible to change the identifier after creation:
It's also possible to change the identifier after creation and while the thread is running:

thread = Titan::Thread.new do
1+1
end
end.run
thread.id = "my_new_thread"

The identifier must be unique.

Titan manages created threads and saves them in a special .titan file that can be found in your home folder.
Titan manages created threads and saves them in pid files inside of a .titan\_threads directory that can be found in your home folder.

You can easily list all available threads:

Expand Down
3 changes: 3 additions & 0 deletions lib/titan/thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def alive?
false
end

#
# Changes the id of the thread and starts synchronization
#
def id=(id)
@@threads.delete(@id)
@id = id
Expand Down

0 comments on commit 9bd1aa7

Please sign in to comment.