Module: Polyphony
- Defined in:
- lib/polyphony.rb,
lib/polyphony/net.rb,
lib/polyphony/version.rb,
lib/polyphony/core/sync.rb,
lib/polyphony/core/debug.rb,
lib/polyphony/core/timer.rb,
lib/polyphony/core/channel.rb,
lib/polyphony/core/throttler.rb,
lib/polyphony/core/exceptions.rb,
lib/polyphony/adapters/process.rb,
lib/polyphony/core/thread_pool.rb,
lib/polyphony/extensions/kernel.rb,
lib/polyphony/core/resource_pool.rb,
ext/polyphony/polyphony.c
Overview
Polyphony API
Defined Under Namespace
Modules: Net, Process, Trace, TrapInterceptor Classes: BaseException, Cancel, Channel, ConditionVariable, Interjection, Monitor, MoveOn, Mutex, Pipe, Queue, ResourcePool, Restart, Terminate, ThreadPool, Throttler, TimeoutException, Timer
Class Method Summary collapse
-
.backend_accept(server_socket, socket_class) ⇒ Socket
Accepts an incoming connection on the given server socket, returning an instance of the given socket class.
-
.backend_accept_loop(server_socket, socket_class) {|Socket| ... } ⇒ nil
Runs an infinite loop accepting connections on the given server socket, returning an instance of the given socket class.
-
.backend_close(io) ⇒ IO, Polyphony::Pipe
Closes the given IO.
-
.backend_connect(io, addr, port) ⇒ Socket
Connects the given socket to the given address and port.
-
.backend_feed_loop(io, receiver, method) ⇒ IO
Runs a feed loop, reading data from the given io, feeding it to the receiver with the given method.
-
.backend_read(io, buffer, length, to_eof, pos) ⇒ String
Reads from the given io.
-
.backend_read_loop(io, maxlen) ⇒ IO
Performs an infinite loop reading data from the given io.
-
.backend_recv(io, buffer, length, pos) ⇒ String
Receives data on the given io.
-
.backend_recv_feed_loop(socket, receiver, method) ⇒ Socket
Runs a feed loop, receiving data on the given socket, feeding it to the receiver with the given method.
-
.backend_recv_loop(socket, maxlen) {|data| ... } ⇒ Socket
Performs an infinite loop receiving data on the given socket.
-
.backend_recvmsg(socket, buffer, maxlen, pos, flags, maxcontrollen, opts) ⇒ String
Receives a message on the given socket.
-
.backend_send(socket, msg, flags) ⇒ Integer
Sends data on the given socket, returning the number of bytes sent.
-
.backend_sendmsg(socket, msg, flags, dest_sockaddr, controls) ⇒ Integer
Sends data on the given socket, returning the number of bytes sent.
-
.backend_sendv(socket, ary, flags) ⇒ Integer
Sends multiple strings on the given socket, returning the number of bytes sent.
-
.backend_sleep(duration) ⇒ nil
Sleeps for the given duration, yielding execution to other fibers.
-
.backend_splice(src, dest, maxlen) ⇒ Integer
Splices data from the given source to the given destination, returning the number of bytes spliced.
-
.backend_timeout(*args) ⇒ Object
Runs the given block, raising an exception if the block has not finished running before a timeout has elapsed, using the given duration.
-
.backend_timer_loop(interval) ⇒ Object
Runs an infinite loop that calls the given block at the specified time interval.
-
.backend_verify_blocking_mode(io, blocking) ⇒ IO, Polyphony::Pipe
Ensures the given IO is in blocking/non-blocking mode.
-
.backend_wait_event(raise) ⇒ Object
For for the current fiber to be rescheduled, resuming the fiber with its resumed value.
-
.backend_wait_io(io, write) ⇒ nil
Waits for the given IO to be readable or writeable, according to the read_or_write parameter.
-
.backend_waitpid(pid) ⇒ Integer
Waits for the given process to terminate, returning its exit code.
-
.backend_write(*args) ⇒ Object
Writes one or more strings to the given io, returning the total number of bytes written.
-
.pipe ⇒ Polyphony::Pipe
Creates a new Polyphony::Pipe instance.
-
.watch_process(cmd = nil, &block) ⇒ Object
Launches a process using either a command or a block for a forked process, waiting for the child process to terminate.
Class Method Details
.backend_accept(server_socket, socket_class) ⇒ Socket
Accepts an incoming connection on the given server socket, returning an instance of the given socket class.
67 68 69 |
# File 'ext/polyphony/polyphony.c', line 67
VALUE Polyphony_backend_accept(VALUE self, VALUE server_socket, VALUE socket_class) {
return Backend_accept(BACKEND(), server_socket, socket_class);
}
|
.backend_accept_loop(server_socket, socket_class) {|Socket| ... } ⇒ nil
Runs an infinite loop accepting connections on the given server socket, returning an instance of the given socket class.
80 81 82 |
# File 'ext/polyphony/polyphony.c', line 80
VALUE Polyphony_backend_accept_loop(VALUE self, VALUE server_socket, VALUE socket_class) {
return Backend_accept_loop(BACKEND(), server_socket, socket_class);
}
|
.backend_close(io) ⇒ IO, Polyphony::Pipe
Closes the given IO.
400 401 402 |
# File 'ext/polyphony/polyphony.c', line 400
VALUE Polyphony_backend_close(VALUE self, VALUE io) {
return Backend_close(BACKEND(), io);
}
|
.backend_connect(io, addr, port) ⇒ Socket
Connects the given socket to the given address and port.
93 94 95 |
# File 'ext/polyphony/polyphony.c', line 93
VALUE Polyphony_backend_connect(VALUE self, VALUE io, VALUE addr, VALUE port) {
return Backend_connect(BACKEND(), io, addr, port);
}
|
.backend_feed_loop(io, receiver, method) ⇒ IO
Runs a feed loop, reading data from the given io, feeding it to the receiver with the given method. The loop terminates when EOF is encountered. If a block is given, it is used as the block for the method call to the receiver.
108 109 110 |
# File 'ext/polyphony/polyphony.c', line 108
VALUE Polyphony_backend_feed_loop(VALUE self, VALUE io, VALUE receiver, VALUE method) {
return Backend_feed_loop(BACKEND(), io, receiver, method);
}
|
.backend_read(io, buffer, length, to_eof, pos) ⇒ String
Reads from the given io.
123 124 125 |
# File 'ext/polyphony/polyphony.c', line 123
VALUE Polyphony_backend_read(VALUE self, VALUE io, VALUE buffer, VALUE length, VALUE to_eof, VALUE pos) {
return Backend_read(BACKEND(), io, buffer, length, to_eof, pos);
}
|
.backend_read_loop(io, maxlen) ⇒ IO
Performs an infinite loop reading data from the given io. The loop terminates when EOF is encountered.
136 137 138 |
# File 'ext/polyphony/polyphony.c', line 136
VALUE Polyphony_backend_read_loop(VALUE self, VALUE io, VALUE maxlen) {
return Backend_read_loop(BACKEND(), io, maxlen);
}
|
.backend_recv(io, buffer, length, pos) ⇒ String
Receives data on the given io.
150 151 152 |
# File 'ext/polyphony/polyphony.c', line 150
VALUE Polyphony_backend_recv(VALUE self, VALUE io, VALUE buffer, VALUE length, VALUE pos) {
return Backend_recv(BACKEND(), io, buffer, length, pos);
}
|
.backend_recv_feed_loop(socket, receiver, method) ⇒ Socket
Runs a feed loop, receiving data on the given socket, feeding it to the receiver with the given method. The loop terminates when EOF is encountered. If a block is given, it is used as the block for the method call to the receiver.
195 196 197 |
# File 'ext/polyphony/polyphony.c', line 195
VALUE Polyphony_backend_recv_feed_loop(VALUE self, VALUE socket, VALUE receiver, VALUE method) {
return Backend_recv_feed_loop(BACKEND(), socket, receiver, method);
}
|
.backend_recv_loop(socket, maxlen) {|data| ... } ⇒ Socket
Performs an infinite loop receiving data on the given socket. The loop terminates when the socket is closed.
179 180 181 |
# File 'ext/polyphony/polyphony.c', line 179
VALUE Polyphony_backend_recv_loop(VALUE self, VALUE socket, VALUE maxlen) {
return Backend_recv_loop(BACKEND(), socket, maxlen);
}
|
.backend_recvmsg(socket, buffer, maxlen, pos, flags, maxcontrollen, opts) ⇒ String
Receives a message on the given socket.
166 167 168 |
# File 'ext/polyphony/polyphony.c', line 166
VALUE Polyphony_backend_recvmsg(VALUE self, VALUE socket, VALUE buffer, VALUE maxlen, VALUE pos, VALUE flags, VALUE maxcontrollen, VALUE opts) {
return Backend_recvmsg(BACKEND(), socket, buffer, maxlen, pos, flags, maxcontrollen, opts);
}
|
.backend_send(socket, msg, flags) ⇒ Integer
Sends data on the given socket, returning the number of bytes sent.
208 209 210 |
# File 'ext/polyphony/polyphony.c', line 208
VALUE Polyphony_backend_send(VALUE self, VALUE socket, VALUE msg, VALUE flags) {
return Backend_send(BACKEND(), socket, msg, flags);
}
|
.backend_sendmsg(socket, msg, flags, dest_sockaddr, controls) ⇒ Integer
Sends data on the given socket, returning the number of bytes sent.
222 223 224 |
# File 'ext/polyphony/polyphony.c', line 222
VALUE Polyphony_backend_sendmsg(VALUE self, VALUE socket, VALUE msg, VALUE flags, VALUE dest_sockaddr, VALUE controls) {
return Backend_sendmsg(BACKEND(), socket, msg, flags, dest_sockaddr, controls);
}
|
.backend_sendv(socket, ary, flags) ⇒ Integer
Sends multiple strings on the given socket, returning the number of bytes sent.
235 236 237 |
# File 'ext/polyphony/polyphony.c', line 235
VALUE Polyphony_backend_sendv(VALUE self, VALUE socket, VALUE ary, VALUE flags) {
return Backend_sendv(BACKEND(), socket, ary, flags);
}
|
.backend_sleep(duration) ⇒ nil
Sleeps for the given duration, yielding execution to other fibers.
245 246 247 |
# File 'ext/polyphony/polyphony.c', line 245
VALUE Polyphony_backend_sleep(VALUE self, VALUE duration) {
return Backend_sleep(BACKEND(), duration);
}
|
.backend_splice(src, dest, maxlen) ⇒ Integer
Splices data from the given source to the given destination, returning the number of bytes spliced. If maxlen is negative, splices repeatedly using absolute value of maxlen until EOF is encountered.
259 260 261 |
# File 'ext/polyphony/polyphony.c', line 259
VALUE Polyphony_backend_splice(VALUE self, VALUE src, VALUE dest, VALUE maxlen) {
return Backend_splice(BACKEND(), src, dest, maxlen);
}
|
.backend_timeout(duration) ⇒ any .backend_timeout(duration, exception_class) ⇒ any
Runs the given block, raising an exception if the block has not finished running before a timeout has elapsed, using the given duration. If an exception class is not given, a TimeoutError is raised.
292 293 294 |
# File 'ext/polyphony/polyphony.c', line 292
VALUE Polyphony_backend_timeout(int argc,VALUE *argv, VALUE self) {
return Backend_timeout(argc, argv, BACKEND());
}
|
.backend_timer_loop(interval) ⇒ Object
Runs an infinite loop that calls the given block at the specified time interval.
301 302 303 |
# File 'ext/polyphony/polyphony.c', line 301
VALUE Polyphony_backend_timer_loop(VALUE self, VALUE interval) {
return Backend_timer_loop(BACKEND(), interval);
}
|
.backend_verify_blocking_mode(io, blocking) ⇒ IO, Polyphony::Pipe
Ensures the given IO is in blocking/non-blocking mode.
411 412 413 |
# File 'ext/polyphony/polyphony.c', line 411
VALUE Polyphony_backend_verify_blocking_mode(VALUE self, VALUE io, VALUE blocking) {
return Backend_verify_blocking_mode(BACKEND(), io, blocking);
}
|
.backend_wait_event(raise) ⇒ Object
For for the current fiber to be rescheduled, resuming the fiber with its resumed value. If raise is true and the resumed value is an exception, an exception will be raised.
312 313 314 |
# File 'ext/polyphony/polyphony.c', line 312
VALUE Polyphony_backend_wait_event(VALUE self, VALUE raise) {
return Backend_wait_event(BACKEND(), raise);
}
|
.backend_wait_io(io, write) ⇒ nil
Waits for the given IO to be readable or writeable, according to the read_or_write parameter.
324 325 326 |
# File 'ext/polyphony/polyphony.c', line 324
VALUE Polyphony_backend_wait_io(VALUE self, VALUE io, VALUE write) {
return Backend_wait_io(BACKEND(), io, write);
}
|
.backend_waitpid(pid) ⇒ Integer
Waits for the given process to terminate, returning its exit code.
334 335 336 |
# File 'ext/polyphony/polyphony.c', line 334
VALUE Polyphony_backend_waitpid(VALUE self, VALUE pid) {
return Backend_waitpid(BACKEND(), pid);
}
|
.backend_write(*args) ⇒ Object
Writes one or more strings to the given io, returning the total number of bytes written.
342 343 344 |
# File 'ext/polyphony/polyphony.c', line 342
VALUE Polyphony_backend_write(int argc, VALUE *argv, VALUE self) {
return Backend_write_m(argc, argv, BACKEND());
}
|
.pipe ⇒ Polyphony::Pipe
Creates a new Polyphony::Pipe instance.
25 26 27 |
# File 'lib/polyphony.rb', line 25 def pipe Pipe.new end |