Confuto
Conjurer


Group: Members
Posts: 115
Joined: Nov 1, 2008
|
#1 id:36164 Posted Oct 12, 2009, 6:54 am
|
I've been tinkering with RocketMUD a bit and am wondering what line 157 in rocket.rb does:
Code (text): 1
2
3 | rFd, dummy, dummy = select(rFd, nil, nil, tv) |
|
|
|
Runter
Wizard


Group: Members
Posts: 1,851
Joined: Jun 1, 2006
|
#2 id:36166 Posted Oct 12, 2009, 7:23 am
|
The same thing select() does in the C version. It's likely a wrapper in Ruby. To be honest, though, I always use the higher level libraries in Ruby.
|
......................... CoralMud project
For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
Leonardo Da Vinci Yukihiro Matsumoto
|
|
Chris Bailey
Wizard

Group: Members
Posts: 602
Joined: Sep 13, 2008
|
#3 id:36175 Posted Oct 12, 2009, 9:01 am
|
It's Runter! Anyways, Runt has that one pegged...and those "higher" level libraries he mentioned are very nice indeed. Eventmachine especially, it's blazing fast.
|
|
......................... If what Proust says is true, that happiness is the absence of fever, then I will never know happiness. For I am possessed by a fever for knowledge, experience, and creation.
|
|
Runter
Wizard


Group: Members
Posts: 1,851
Joined: Jun 1, 2006
|
#4 id:36177 Posted Oct 12, 2009, 9:06 am
|
Chris Bailey said:It's Runter! Anyways, Runt has that one pegged...and those "higher" level libraries he mentioned are very nice indeed. Eventmachine especially, it's blazing fast.
Yeah. I'll probably be around more now. I find the place more hospitable.
|
......................... CoralMud project
For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
Leonardo Da Vinci Yukihiro Matsumoto
|
|
Confuto
Conjurer


Group: Members
Posts: 115
Joined: Nov 1, 2008
|
#5 id:36283 Posted Oct 13, 2009, 8:27 pm
|
Thanks, think I have it figured out now. Bit of a Ruby novice.
|
|
|
JohnnyStarr
Wizard


Group: Members
Posts: 823
Joined: Feb 14, 2009
|
#6 id:36308 Posted Oct 14, 2009, 1:42 pm
|
Chris Bailey said:It's Runter! Anyways, Runt has that one pegged...and those "higher" level libraries he mentioned are very nice indeed. Eventmachine especially, it's blazing fast.
Is "Eventmachine" multi threaded? Is there a way to use non-blocking sockets with it?
|
.........................
"It's not the daily increase but daily decrease. Hack away at the unessential." - Bruce Lee
Southlake Window Cleaner
|
|
|
|
JohnnyStarr
Wizard


Group: Members
Posts: 823
Joined: Feb 14, 2009
|
#8 id:36316 Posted Oct 14, 2009, 7:15 pm
|
David Haley said:I can't answer your specific Eventmachine questions, but note that non-blocking sockets can be used without a multithreaded application.
I asked this question because most multi-threaded I/O engines use blocking sockets,
not the other way around. So, because I only saw mulit-threaded examples on Eventmachine's Wiki, I assumed that if it was multi-threaded, it used blocking sockets.
|
.........................
"It's not the daily increase but daily decrease. Hack away at the unessential." - Bruce Lee
Southlake Window Cleaner
|
|
Runter
Wizard


Group: Members
Posts: 1,851
Joined: Jun 1, 2006
|
#9 id:36317 Posted Oct 14, 2009, 8:26 pm
|
EventMachine uses a reactor model. Not a threaded one. I'm not sure if the C implementation matters since you can't access resources out of the prescribed way. According to the documentation this prescribed way is guaranteed to be non-blocking.
EventMachine is written in C and it's much more scalable and more sensitive to the needs of many projects than some pure Ruby solutions will be. My tests with it have proven it to be more than efficient enough for my needs. (But to be honest, more than likely hte other less efficient libraries would have been as well.) One of my biggest problems with EventMachine was the lack of Ruby examples however there is pretty solid documentation for the classes. It's a library available for Java, C++, and Ruby.
There's other alternatives in Ruby like gserver or just the native socket library. There's wrappers for the low level C function calls as well.
|
......................... CoralMud project
For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
Leonardo Da Vinci Yukihiro Matsumoto
Last edited Oct 14, 2009, 8:41 pm by Runter
|
|
|
|
Chris Bailey
Wizard

Group: Members
Posts: 602
Joined: Sep 13, 2008
|
#11 id:36319 Posted Oct 14, 2009, 8:49 pm
|
If you are interesting in Ruby solutions you can also check out the networking side of Tyches Teensymud, it's pretty sweet actually.
EDIT: The actually kind of implied that I was surprised that it was good or something. It just came out that way, I'm tired. It's good, plain and simple.
|
|
......................... If what Proust says is true, that happiness is the absence of fever, then I will never know happiness. For I am possessed by a fever for knowledge, experience, and creation.
Last edited Oct 14, 2009, 8:50 pm by Chris Bailey
|
|
Runter
Wizard


Group: Members
Posts: 1,851
Joined: Jun 1, 2006
|
#12 id:36320 Posted Oct 14, 2009, 8:50 pm
|
Chris Bailey said:If you are interesting in Ruby solutions you can also check out the networking side of Tyches Teensymud, it's pretty sweet actually.
Whatever happened to that being released in a gem? *pokes tyche*
|
......................... CoralMud project
For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
Leonardo Da Vinci Yukihiro Matsumoto
|
|
Tyche
Wizard


Group: Members
Posts: 1,349
Joined: May 23, 2006
|
#13 id:36347 Posted Oct 15, 2009, 5:48 pm
|
Runter said:
Chris Bailey said:If you are interesting in Ruby solutions you can also check out the networking side of Tyches Teensymud, it's pretty sweet actually.
Whatever happened to that being released in a gem? *pokes tyche*
Sorry. I need to get cracking on releasing more code. ;-)
|
.........................  
For now we see through a glass, darkly; but then face to face: now I know in part; but then shall I know even as also I am known.
|
|
Chris Bailey
Wizard

Group: Members
Posts: 602
Joined: Sep 13, 2008
|
#14 id:36384 Posted Oct 16, 2009, 2:52 pm
|
Tyche said:Sorry. I need to get cracking on releasing more code. ;-)
I agree.
|
|
......................... If what Proust says is true, that happiness is the absence of fever, then I will never know happiness. For I am possessed by a fever for knowledge, experience, and creation.
|
|
JohnnyStarr
Wizard


Group: Members
Posts: 823
Joined: Feb 14, 2009
|
#15 id:36471 Posted Oct 18, 2009, 12:56 am
|
Hey, I came up with a nifty color code system of my own, just wanted to throw this out there on a RocketMud
post.
I ran with the RocketMud idea of the color table, but everything else is new.
The cool thing about it is by using '#' as background and '{' as foreground, it allows you to easily use both without having
to add color codes.
Code (text): 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 |
# first create the color class
class Color
attr_accessor :char, :code, :bold
def initialize (char, code, bold)
@char = char
@code = code
@bold = bold
end
end
# add a global color list
$colors = [
Color.new(?d, "0m", false),
Color.new(?D, "0m", true),
Color.new(?r, "1m", false),
Color.new(?R, "1m", true),
Color.new(?g, "2m", false),
Color.new(?G, "2m", true),
Color.new(?y, "3m", false),
Color.new(?Y, "3m", true),
Color.new(?b, "4m", false),
Color.new(?B, "4m", true),
Color.new(?p, "5m", false),
Color.new(?P, "5m", true),
Color.new(?c, "6m", false),
Color.new(?C, "6m", true),
Color.new(?w, "7m", false),
Color.new(?W, "7m", true),
Color.new(?x, "7m", false)] # default
# then add this to your (to_buffer) or what have you
def to_buffer(buf)
i = 0
while i < buf.size
fb = 0
fb = 3 if buf[i] == ?{
fb = 4 if buf[i] == ?#
i += 1
unless fb == 0
valid = false
$colors.each { |c|
b = c.bold ? 1 : 0
if buf[i] == c.char
buf[i-1..i] = "\e[#{b};#{fb}#{c.code}"
valid = true
break
end
}
unless valid
log.debug("Bad color character: #{buf[i..i]}")
buf[i-1] = '' # set char to null if invalid
end
end
end
send_data(buf)
end
|
|
.........................
"It's not the daily increase but daily decrease. Hack away at the unessential." - Bruce Lee
Southlake Window Cleaner
Last edited Oct 18, 2009, 1:11 am by staryavsky
|
|