-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 906b73a
Showing
7 changed files
with
724 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Copyright 2011 Marcel Laverdet | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to | ||
deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
sell copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
IN THE SOFTWARE. | ||
|
||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|
||
I am providing code in this repository to you under an open source license. | ||
Because this is my personal repository, the license you receive to my code is | ||
from me and not from my employer (Facebook). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
NODE_PREFIX := $(shell node --vars | egrep ^NODE_PREFIX: | cut -c14-) | ||
# CPPFLAGS = -ggdb -O0 -Wall -I$(NODE_PREFIX)/include -I$(NODE_PREFIX)/include/node -I/Users/marcel/code/v8/include | ||
CPPFLAGS = -m64 -ggdb -O0 -Wall -I$(NODE_PREFIX)/include -I$(NODE_PREFIX)/include/node | ||
|
||
all: node-fibers.node | ||
|
||
coroutine.dylib: coroutine.cc | ||
$(CXX) $(CPPFLAGS) -dynamiclib -o $@ $^ | ||
|
||
node-fibers.node: node-fibers.cc coroutine.dylib | ||
$(CXX) $(CPPFLAGS) -bundle -undefined dynamic_lookup -o $@ $^ | ||
|
||
clean: | ||
-$(RM) node-fibers.node coroutine.dylib | ||
-$(RM) -r *.dSYM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Fiber support for Node and v8. | ||
|
||
To build this software: | ||
|
||
make | ||
|
||
Only OS X is supported right now. | ||
|
||
If you intend to use fibers, be sure to start node with the included | ||
`fiber-shim` script. This is a quick example of what you can do with | ||
node-fibers: | ||
|
||
$ cat generator.js | ||
var util = require('util'); | ||
var Fiber = require('./node-fibers').Fiber; | ||
|
||
var inc = Fiber(function(start) { | ||
var total = start; | ||
while (true) { | ||
total += this.yield(total); | ||
} | ||
}); | ||
|
||
for (var ii = inc.run(1); ii < 10; ii = inc.run(1)) { | ||
util.print(ii + '\n'); | ||
} | ||
|
||
$ ./fiber-shim node generator.js | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 |
Oops, something went wrong.