<ryanw-se>
i wasn't very familiar with what evented i/o looks like in a ruby like language, but I notice the thread tends to be Object::<Watcher>, is the :: apart of the whole thing or am I reading into things too much
<ryanw-se>
not thread, theme*
<ryanw-se>
nvm im being stupid again
<jhass>
note this is very different from evented IO ruby libs like EventMachine or Celluloid::IO
<jhass>
API wise at least
<ryanw-se>
yeah im realizing that now
<ryanw-se>
is there any thing I should read / watch so I don't feel completely out of my element with this
<jhass>
not sure there's anything yet, it's also all not finalized yet
<jhass>
I can picture parallelism might change the existing APIs quite drastically
<jhass>
there's also some ideas to language integration to the syntax/keyword level
<ryanw-se>
you said something about how TCPSocket has evented i/o built in, how can I take advantage / use it?
<ryanw-se>
this is what i've currently got, its based off the example in the crystal repo
<jhass>
right, so if a client blocks on reading or writing there and another one comes, it will be handled meanwhile
<jhass>
due to each having their own fiber
<jhass>
or in this case even when your stdout is too busy
<ryanw-se>
right, that makes sense
<ryanw-se>
but what I don't understand, is how I can move away from client.read_line, and actually work with the inputs/outputs (like i would in java)
<ryanw-se>
I don't want to automatically treat everything as a string, i'm basically trying to figure out how to do something like if you were to write to tcp and then flush, but here I just want to run a block everytime new data comes in and handle it accordingly
<ryanw-se>
in its "raw" form
<crystal-gh>
[crystal] jhass opened pull request #2608: Add NamedTupleLiteral#map and HashLiteral#map (master...named_tuple_map) https://git.io/vrlKY
<jhass>
ryanw-se: IO provides a couple of methods to read raw data, but you must know how many bytes you want to read
<jhass>
but the theme isn't "call a block on new data" but "reschedule the fiber when new data is available, run other fibers meanwhile"
<ryanw-se>
jhass: In this case I don't know how many bytes I want to read, because the information being sent to me is being sent in several different types (varint, string, unsigned short, etc)
<ryanw-se>
the string bit works absolutely fine with read_line, its just the stuff like varint and unsigned short that come in all malformed
<jhass>
well there gotta be a type tag or something?
<jhass>
yeah that doesn't specify what the field types actually are
<ryanw-se>
it tells me to expect a varint, then a string, then unsigned short, then another varint
<ryanw-se>
but thats pretty much all it tells me
<jhass>
they don't define "varint" ?
<jhass>
and string could mean with length header or 0 terminated
<jhass>
unsigned short is the only somewhat clear thing, as short happens to be defined fairly platform dependent (iirc ANSI C doesn't guarantee that though)
trapped has quit [Read error: Connection reset by peer]
|2701 has joined #crystal-lang
trapped has joined #crystal-lang
<txdv>
is there a way to wait for all fibers to finish?
<jhass>
I guess you could try reopening Scheduler and wait till @@runnables is empty
<jhass>
not sure that'll even work though
<jhass>
explicitly you could share a channel among all, keep track of how many you have running, do a send before exiting a fiber and n receive's in the main fiber
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Oliphaunte has joined #crystal-lang
grindhold has quit [Quit: No Ping reply in 180 seconds.]
grindhold has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 252 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox_ has joined #crystal-lang
nwmcsween has joined #crystal-lang
nwmcsween is now known as Guest78032
Guest8959 has quit [Ping timeout: 246 seconds]
<txdv>
is it possible to define a struct of a certain size?
<jhass>
well crystal should pick the minimal size
<jhass>
what do you need it for?
<txdv>
i know that the size of the libuvs uv_loop_t is 804 on my system, i just want to create a struct which is that big
<jhass>
we usually do struct LoopT; _data : UInt8[804]; end then
<jhass>
if you don't actually need to allocate it yourself, just alias LoopT = Void
nwmcsween_ has joined #crystal-lang
<txdv>
o it goes inside
<txdv>
well, libuv has a function which returns the sizes of the types
<txdv>
so you don't have to hard code it
<jhass>
mh
<txdv>
but i need to use then malloc
<jhass>
yeah
<jhass>
or you would bind just that function and use a run macro to generate the lib code...
<|2701>
I mentioned this the other day and got no response but (1..100).combinations(3).select{|a,b,c|(a*a)+(b*b)==(c*c)} doesnt bind a,b,c to the elements of the arrays, is there a way to simulate that with any of the new 0.17 features?
Guest78032 has quit [Ping timeout: 260 seconds]
<jhass>
txdv: btw not sure how well mixing libevent and libuv in the same process will go
<|2701>
I'm broke as a joke, but yeah, I'm glad that it's probably going to happen
<txdv>
broke as a joke?
<|2701>
yup
<|2701>
poor life choices
Bish has quit [Remote host closed the connection]
<icezimm>
hahaha I had to go on "urban dictionary" for this expression too hahah
<txdv>
yo, ma man, that ain't no joke
<|2701>
u know it
<txdv>
jhass: nice, all the bindings are there
<txdv>
but are anyway useless if everything is working with libevent just fine
Oliphaunte has joined #crystal-lang
poulet_a has left #crystal-lang [#crystal-lang]
Oliphaunte has quit [Ping timeout: 244 seconds]
<txdv>
jhass: it doesn't have reflection yet though, right?
<txdv>
like, get names and types of arguments of functions
<jhass>
no runtime reflection, but compile time reflection which you can use to to generate code, in the most simple case store the stuff to make it accessible to the runtime
<icezimm>
what's the best way to create an C binding for crystal? use https://github.com/crystal-lang/crystal_lib and put directly on the project? or create a separated shard?
<jhass>
I don't think crystal_lib is production ready yet
<jhass>
at these times, I'd start out with putting it into the project directly and consider extracting to a shard when it proves generally useful/complete enough
<asterite>
jhass: seems like the formatter check failed, but everything should be working fine. Since I already tagged 0.17.1 I'll make a release and then fix this
<tilpner>
This doesn't look sufficient for a precise GC though. Is there tracing type information that I'm missing here?
<jhass>
no that's all, that's simply not available afaik
<jhass>
the interface was built with integrating boehm GC for now in mind after all
<tilpner>
Yes, seems reasonable. Macros might help generate the tracing code though.
<jhass>
what tracing information would you want? reference counting?
Philpax has joined #crystal-lang
<tilpner>
Most simple scenario, a naive mark&sweep. I have a struct, and I can mark it. I also need to mark all GC-ed fields of that struct, to indicate they are still reachable/alive. The tracing code would probably recursively visit all GC-ed fields.
<jhass>
(maybe watch terminology here, crystal structs are stack allocated unless you do Pointer vodoo to heap allocate one)
LastWhisper____ has quit [Ping timeout: 260 seconds]
<tilpner>
How does that affect this? :/
<jhass>
it means they're pass by value and gone the moment the stackframe is gone (the function returns), the GC never sees a Crystal struct instance, opposed to a class instance
<tilpner>
If I have a struct that contains a string, I still need to mark the string, so I can't not trace the struct too, even if the struct itself won't be gc-ed.
<jhass>
mh, right
<tilpner>
But yes, I might confuse terminology a little. :)