This file contains hidden or 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
r:stream():line() --> `err`, `Slice` | |
-- a slice is a restricted `off`, `len` window into a buffer. offers all methods buffer does. | |
-- is bump / growable, if `len` extends to the end of the buffer's current contents. | |
-- this allows you to make use of the line without incurring and additional copy | |
-- you call `:trim` when done with the line. | |
-- buffer (and so slice) will get two new methods |
This file contains hidden or 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
local ffi = require("ffi") | |
local levee = require("levee") | |
ffi.cdef([[ | |
typedef struct { int len; } myproto_prefix_t; | |
]]) | |
This file contains hidden or 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
local ffi = require("ffi") | |
local levee = require("levee") | |
ffi.cdef([[ | |
typedef struct { int len; } myproto_prefix_t; | |
]]) | |
This file contains hidden or 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
local ffi = require("ffi") | |
local levee = require("levee") | |
ffi.cdef([[ | |
typedef struct { int len; } myproto_prefix_t; | |
]]) | |
This file contains hidden or 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
local ffi = require("ffi") | |
local levee = require("levee") | |
ffi.cdef([[ | |
typedef struct { int len; } myproto_prefix_t; | |
]]) | |
This file contains hidden or 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
local ffi = require("ffi") | |
local levee = require("levee") | |
local d = levee.d | |
ffi.cdef([[ | |
typedef struct { int len; } myproto_prefix_t; | |
]]) |
This file contains hidden or 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
#include <assert.h> | |
#include <pthread.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <netdb.h> | |
#include <string.h> | |
#include <errno.h> |
This file contains hidden or 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
local levee = require("levee") | |
local _ = levee._ | |
local RPCThreadPool_mt = {} | |
function RPCThreadPool_mt:__index(name) | |
return function(self, ...) | |
local sender, recver = self.h:pipe() |
This file contains hidden or 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
local levee = require("levee") | |
local _ = levee._ | |
local ThreadPool_mt = {} | |
function ThreadPool_mt:__index(name) | |
return function(self, ...) | |
local sender, recver = self.h:pipe() |
This file contains hidden or 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
local levee = require("levee") | |
local _ = levee._ | |
local h = levee.Hub() | |
_.fcntl_nonblock(0); h.stdin = h.io:r(0) | |
_.fcntl_nonblock(1); h.stdout = h.io:w(1) | |
local stream = h.stdin:stream() |