Permalink
Browse files

cleanup

  • Loading branch information...
1 parent 7af3b1e commit 983ba0ab96cf78556feb5fa9f90303c16a06d780 @bakkdoor committed Nov 19, 2011
Showing with 8 additions and 89 deletions.
  1. +4 −0 lib/block.fy
  2. +0 −1 lib/boot.fy
  3. +4 −10 lib/fiber.fy
  4. +0 −78 lib/fiber_pool.fy
View
@@ -120,6 +120,10 @@ class Block {
call: [val]
}
+ def Block inspect {
+ name
+ }
+
def Block name {
"Block"
}
View
@@ -38,7 +38,6 @@ require: "stack"
require: "proxy"
require: "thread_pool"
require: "fiber"
-require: "fiber_pool"
require: "future"
require: "struct"
View
@@ -6,17 +6,11 @@ class Fiber {
There is no preemptive scheduler.
"""
- def sleep: seconds {
- @sleep_end = Time now + seconds
- }
-
- def asleep? {
- if: @sleep_end then: {
- Time now < @sleep_end
- }
- }
-
def Fiber name {
"Fiber"
}
+
+ def Fiber inspect {
+ name
+ }
}
View
@@ -1,78 +0,0 @@
-class FiberPool {
- def initialize {
- @pool = []
- @scheduling = false
- @mutex = Mutex new()
- }
-
- def size {
- @mutex synchronize() {
- @pool size
- }
- }
-
- def add: fiber {
- @mutex synchronize() {
- @pool << fiber
- }
- }
-
- def remove: fiber {
- @mutex synchronize() {
- @pool remove: fiber
- }
- }
-
- def scheduling? {
- @scheduling
- }
-
- def pool {
- @mutex synchronize() {
- pool = @pool
- }
- }
-
- def cleanup_pool {
- @mutex synchronize() {
- @pool select!: 'alive?
- }
- }
-
- def schedule {
- @scheduling = true
- Thread new: {
- loop: {
- while: {pool size > 0} do: {
- pool each: |f| {
- unless: (f asleep?) do: {
- sleep_time = f resume
- { f sleep: sleep_time } if: sleep_time
- }
- }
- cleanup_pool
- }
- Thread sleep: 1
- }
- }
- }
-}
-
-class Scheduler {
- @@pool = FiberPool new
- def Scheduler add: fiber {
- @@pool add: fiber
- unless: (@@pool scheduling?) do: {
- schedule
- }
- nil
- }
-
- def Scheduler remove: fiber {
- @@pool remove: fiber
- }
-
- def Scheduler schedule {
- @@pool schedule
- }
-}

0 comments on commit 983ba0a

Please sign in to comment.