<commit_before>Eventless
=========

Eventless aspires to be a concurrent networking library for Ruby that lets you write asynchronous, event driven code that looks like normal, blocking code. It uses Fibers, so it requires Ruby 1.9. It also uses Marc Lehmann's libev (currently via cool.io). Eventless is inspired heavily by [gevent](http://gevent.org).

Right now it's all in one file and really more of an experiment, but I'm working hard on that.

##How it works

Eventless monkey patches `Socket` to make it's API asynchronous. All of your code runs in a `Fiber`. You can make new fibers using `Eventless.spawn`. `Fiber.new` _will not_ work. Your code should look exactly the same, but when you call something that normally blocks, your fiber gets put to sleep on the event loop and gets woken up when there is data to be read or written.

Because Eventless monkey patches the core library (eww, gross, I know), any networking library that is written in pure Ruby should just work (tm). You should eventually be able to write code like this:

```ruby
require 'eventless'
require 'open-uri'

jobs = %w(http://www.google.com/, http://github.com/, http://ruby-lang.org/).map do |url|
  Eventless.spawn do
    open(url) { |f| f.read }
  end
end

pages = Eventless.joinall(jobs)
```

It's really far away from that though. Right now you can just do this:

```ruby
require 'eventless'

fibers = []
5.times do
  fibers << Eventless.spawn { sleep 2 }
end

fibers.each { |f| f.join }
```

Even though you've spawned five fibers that sleep for two seconds a piece, this code should only take two seconds to run.

##Install

It will probably crash or not work, but:

    $ git clone git://github.com/davidbalbert/eventless.git
    $ cd eventless
    $ ruby lib/eventless.rb

##Status

The event loop seems to be working. Fibers do not yet deal with exceptions. This will have to be added. I'm also not very happy with how the event loop internal api is turning out. Will refactor soon.

I'm pretty sure the socket code in there doesn't work yet. It doesn't seem to run concurrently yet, and I have to figure out why. This might be due to bugs in the event loop that I may have fixed.

On the bright side, `Kernel#sleep` successfully transfers control to the event loop rather than blocking.

##Contributing

The current goal is to replace all blocking methods in `Socket` with API compatible versions that transfer control to the event loop rather than block. When in doubt, read the code for gevent, but write your code like a Rubyist would.

##License<commit_msg>updated README with current status<commit_after>Eventless
=========

Eventless aspires to be a concurrent networking library for Ruby that lets you write asynchronous, event driven code that looks like normal, blocking code. It uses Fibers, so it requires Ruby 1.9. It also uses <NAME>hmann's libev (currently via cool.io). Eventless is inspired heavily by [gevent](http://gevent.org).

Right now it's all in one file and really more of an experiment, but I'm working hard on that.

##How it works

Eventless monkey patches `Socket` to make it's API asynchronous. All of your code runs in a `Fiber`. You can make new fibers using `Eventless.spawn`. `Fiber.new` _will not_ work. Your code should look exactly the same, but when you call something that normally blocks, your fiber gets put to sleep on the event loop and gets woken up when there is data to be read or written.

Because Eventless monkey patches the core library (eww, gross, I know), any networking library that is written in pure Ruby should just work (tm). You should eventually be able to write code like this:

```ruby
require 'eventless'
require 'open-uri'

jobs = %w(http://www.google.com/, http://github.com/, http://ruby-lang.org/).map do |url|
  Eventless.spawn do
    open(url) { |f| f.read }
  end
end

pages = Eventless.joinall(jobs)
```

It's really far away from that though. Right now you can just do this:

```ruby
require 'eventless'

fibers = []
5.times do
  fibers << Eventless.spawn { sleep 2 }
end

fibers.each { |f| f.join }
```

Even though you've spawned five fibers that sleep for two seconds a piece, this code should only take two seconds to run.

##Install

It will probably crash or not work, but:

    $ git clone git://github.com/davidbalbert/eventless.git
    $ cd eventless/examples       # run some of these

##Status

###What works
- The event loop
- Exception handling in `Fiber`
- `Kernel#sleep`

###What doesn't work
- The socket code
- Everything else

The socket code doesn't seem to run concurrently yet. I have to figure out why. This might be due to bugs in the event loop that I may have fixed.

##Contributing

The current goal is to replace all blocking methods in `Socket` with API compatible versions that transfer control to the event loop rather than block. When in doubt, read the code for gevent, but write your code like a Rubyist would.

##License
{'fraction_non_alphanumeric': 0.07759496242128783, 'fraction_numerical': 0.0016250253910217347, 'mean_word_length': 3.9338677354709417, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '997793', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1342, 'n_words': 745}