oldmoe-neverblock 0.1.6 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/never_block.rb +5 -78
- data/lib/neverblock.rb +3 -1
- data/lib/{never_block/extensions/fiber_extensions.rb → neverblock/core/fiber.rb} +20 -6
- data/lib/neverblock/core/pool.rb +72 -0
- data/lib/neverblock/core/reactor.rb +50 -0
- data/lib/neverblock/core/system/system.rb +38 -0
- data/lib/neverblock/core/system/timeout.rb +67 -0
- data/lib/{never_block/db/pooled_db_connection.rb → neverblock/io/db/connection.rb} +16 -2
- data/lib/neverblock/io/db/drivers/mysql.rb +73 -0
- data/lib/neverblock/io/db/drivers/postgres.rb +63 -0
- data/lib/neverblock/io/db/fibered_connection_pool.rb +130 -0
- data/lib/{never_block → neverblock/io}/db/fibered_mysql_connection.rb +5 -18
- data/lib/{never_block/pool/fibered_connection_pool.rb → neverblock/io/db/pool.rb} +25 -40
- data/lib/neverblock/io/file.rb +24 -0
- data/lib/neverblock/io/io.rb +219 -0
- data/lib/neverblock/io/socket.rb +75 -0
- data/lib/neverblock_io.rb +6 -0
- data/lib/system.rb +4 -0
- data/neverblock.gemspec +23 -21
- metadata +23 -20
- data/lib/active_record/connection_adapters/neverblock_mysql_adapter.rb +0 -68
- data/lib/active_record/connection_adapters/neverblock_postgresql_adapter.rb +0 -85
- data/lib/never_block/db/fibered_db_connection.rb +0 -72
- data/lib/never_block/db/fibered_postgres_connection.rb +0 -64
- data/lib/never_block/frameworks/activerecord.rb +0 -37
- data/lib/never_block/frameworks/rails.rb +0 -65
- data/lib/never_block/pool/fiber_pool.rb +0 -74
- data/lib/never_block/servers/mongrel.rb +0 -236
- data/lib/never_block/servers/thin.rb +0 -32
- data/lib/neverblock-mysql.rb +0 -5
- data/lib/neverblock-pg.rb +0 -5
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'neverblock' unless defined?(NeverBlock)
|
3
|
-
require 'thin'
|
4
|
-
|
5
|
-
module Thin
|
6
|
-
|
7
|
-
# Patch the thin server to use NeverBlock::Pool::FiberPool to be able to
|
8
|
-
# wrap requests in fibers
|
9
|
-
class Server
|
10
|
-
|
11
|
-
DEFAULT_FIBER_POOL_SIZE = 20
|
12
|
-
|
13
|
-
def fiber_pool
|
14
|
-
@fiber_pool ||= NB::Pool::FiberPool.new(DEFAULT_FIBER_POOL_SIZE)
|
15
|
-
end
|
16
|
-
|
17
|
-
end # Server
|
18
|
-
|
19
|
-
# A request is processed by wrapping it in a fiber from the fiber pool.
|
20
|
-
# If all the fibers are busy the request will wait in a queue to be picked up
|
21
|
-
# later. Meanwhile, the server will still be processing requests
|
22
|
-
class Connection < EventMachine::Connection
|
23
|
-
|
24
|
-
def process
|
25
|
-
@request.threaded = false
|
26
|
-
@backend.server.fiber_pool.spawn {post_process(pre_process)}
|
27
|
-
end
|
28
|
-
|
29
|
-
end # Connection
|
30
|
-
|
31
|
-
|
32
|
-
end # Thin
|
data/lib/neverblock-mysql.rb
DELETED