Permalink
Browse files

remove dependences, create a default pool in global scope

  • Loading branch information...
1 parent c62e72c commit 3c338792834c6485b8a8adbb57ee037e062ec2fb @neutra committed Apr 2, 2013
Showing with 27 additions and 44 deletions.
  1. +11 −22 lib/merge_pool.js
  2. +1 −1 lib/merge_pool.map
  3. +11 −15 src/merge_pool.coffee
  4. +1 −2 test/test.coffee
  5. +3 −4 test/test.js
View
Oops, something went wrong.
View
@@ -6,5 +6,5 @@
"src\\merge_pool.coffee"
],
"names": [],
- "mappings": ";AAAA;CAAA,KAAA,sBAAA;KAAA,aAAA;;CAAA,CAAA,CAAO,CAAP,EAAO,CAAA;;CAAP,CACA,CAAQ,EAAR,EAAQ;;CADR,CAGA,CAAO,CAAP,KAAQ;CACC,EAAR,CAAA,GAAO,IAAP,EAAa;CAJd,EAGO;;CAHP,CAMM;CACL;;;;;CAKa,EAAA,CAAA,eAAC;;GAAI,KAAJ;QACb;CAAA;;;;;CAAA;CAAA,CAAA,CAKY,CAAX,EAAD,EAAA;AACU,CANV,EAMS,CAAR,CAAD,CAAA;CAZD,IAKa;;CALb,EAcA,MAAK;CACJ,SAAA,2CAAA;SAAA,GAAA;;CAAA,CADS,IAAJ;CACL;;;;;;CAAA;CAQA,GAAO,EAAP,KAAA;CACC,GAAU,CAAA,SAAA,2BAAA;QATX;AAUmB,CAAnB,EAAA,CAAO,CAAY,CAAnB,EAAO;CACN,EAAA,KAAA;QAXD;AAYqB,CAArB,GAAO,CAAc,CAArB,IAAO;CACN,GAAU,CAAA,SAAA,0BAAA;QAbX;AAcqB,CAArB,GAAO,CAAc,CAArB,EAAA,EAAO;CACN,GAAU,CAAA,SAAA,8BAAA;QAfX;CAAA,EAkBO,CAAP,EAAA;CAAO,CAAC,MAAA;CAlBR,OAAA;CAAA,EAmBQ,CAAC,CAAT,CAAA,EAAkB;CAClB,GAAG,EAAH,OAAA;CACC,GAAA,CAAK,GAAL;CACA,aAAA;QAtBD;CAAA,EAuBQ,CAAA,CAAR,CAAA;CAvBA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EAAH,OAAA;CACC,GAAA,CAAK,GAAL;CACA,aAAA;QApBD;CAAA,EAqBQ,CAAA,CAAR,CAAA;CArBA,EAsBU,CAAT,CAtBD,CAsBA,EAAU;CAtBV,CAwBY,CAAL,CAAP,EAAA,GAAQ;AACP,CAAA,EAAiB,EAAT,CAAR,EAAA;CACA,EAAqB,CAAA,EAArB,EAAA,IAAoC;CAApC,EAAA,GAAM,IAAN;UADA;CAEA,GAAwB,EAAA,EAAxB,IAA0C;CAA1C,KAAM,IAAN;UAFA;CAGM,EAAQ,CAAA,CAAT,EAAL,EAAe,MAAf;CACM,CAAgB,CAArB,CAAI,CAAJ,CAAA,EAAa,SAAb;CADD,QAAc;CA5Bf,MAwBO;CAQP;CACC,CAAiB,EAAb,CAAJ,GAAA,KAAiB;MADlB,EAAA;CAGC,KAAA,EADK;CACL,EAAiB,IAAV,CAAP,CAAiB;CAAQ,EAAL,CAAA,aAAA;CAApB,QAAiB;QApCd;CAlBL,IAkBK;;CAlBL;;CADD;;AA0DiB,CA1DjB,CA0DA,CAAiB,GAAX,CAAN,EA1DA;CAAA"
}
View
@@ -1,24 +1,22 @@
-util = require 'util'
-async = require 'async'
-
-_log = (text) ->
- console.log "MergePool: #{text}"
-
class MergePool
###
Merge Pool
merge multi requests, process one and response all the same requests
###
- constructor: (opt={}) ->
+
+ constructor: ->
###
constructor
- > @opt:
- > debug:
###
@pendings = {}
- @debug = !!opt.debug
-
+
+ create: ->
+ ###
+ create new MergePool instance
+ ###
+ new MergePool
+
run: (key,exec,args...,callback) ->
###
run(key,exec,args...,callback)
@@ -28,10 +26,8 @@ class MergePool
###
# check params
- unless key?
- throw new Error 'MergePool.run: key can not must be null'
unless 'string' is typeof key
- key = key.toString()
+ throw new Error 'MergePool.run: key can not must be a string'
unless 'function' is typeof exec
throw new Error 'MergePool.run: exec must be a function'
unless 'function' is typeof callback
@@ -60,4 +56,4 @@ class MergePool
process.nextTick -> done err
return
-module.exports = MergePool
+module.exports = new MergePool
View
@@ -1,10 +1,9 @@
async = require 'async'
assert = require 'assert'
-MergePool = require '../lib/merge_pool'
+mp = require '../lib/merge_pool'
exports.test = (test) ->
- mp = new MergePool
outputs = null
echo = (input,cb) ->
console.log "accept input: #{input}"
View
Oops, something went wrong.

0 comments on commit 3c33879

Please sign in to comment.