Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:10
    straight-shoota opened #11361
  • 16:10
    straight-shoota labeled #11361
  • 16:10
    straight-shoota labeled #11361
  • 16:10
    straight-shoota labeled #11361
  • 16:10
    straight-shoota labeled #11361
  • 15:14
    straight-shoota synchronize #11360
  • 15:00
    straight-shoota synchronize #11360
  • 14:59
    straight-shoota synchronize #11360
  • 14:44
    Blacksmoke16 synchronize #11325
  • 13:30
    straight-shoota labeled #11360
  • 13:30
    straight-shoota labeled #11360
  • 13:30
    straight-shoota opened #11360
  • 12:51
    straight-shoota closed #11289
  • 12:51
    straight-shoota closed #11274
  • 12:50
    straight-shoota closed #11321
  • 12:50
    straight-shoota closed #11319
  • 12:50
    straight-shoota closed #11288
  • 12:49
    straight-shoota review_request_removed #11233
  • 12:48
    straight-shoota synchronize #11359
  • 12:23
    henrikac closed #11356
From IRC (bridge bot)
@FromIRC
<frojnd> Hi there
<frojnd> I just noticeds under project/lib I have files of shards I removed from shard.yml How do I clean not used shard files?
George Dietrich
@Blacksmoke16
shards prune would prob d oit
do it
From IRC (bridge bot)
@FromIRC
<frojnd> Thank you
From IRC (bridge bot)
@FromIRC
<Guest59> Hey all. Is there a way to emulate similar behavior to dynamic function calls on c? (Ex https://stackoverflow.com/a/840504)
<Guest59> I've been trying to use Proc.new(pointer-addr, etc) but I'm getting hung up on the second parameter
<Guest59> I have the functions address stored in a pointer object already, but I can't figure out how to call it
<yxhuvud> You better post a short code example of what you want to acheive.
From IRC (bridge bot)
@FromIRC
<Guest59> Hmm I'll have to check back later. I'm mobile at the moment, but I may have figured it out after looking at some more proc examples
<Guest59> But maybe someone could shine some light on this proc methods second parameter
<Guest59> .new(pointer : Pointer(Void), closure_data : Pointer(Void)) : Pointer(Void), closure_data : Pointer(Void))
<Guest59> Well that didn't paste good, but what is clousure_data
Chris Watson
@watzon
Guest59: Hard to know without some context. Where is this method defined?
From IRC (bridge bot)
@FromIRC
<elf_fortrez> i guess in the client
postmodern
@postmodern:matrix.org
[m]
@asterite: raw syscalls are mostly only useful for accessing OS-specific syscalls that libc doesn't support. Use case is mostly for libraries, so raw sysacall(2) access could be provided via a shard.
Quinton Miller
@HertzDevil
if the proc comes from crystal it contains the closure data
if the proc comes from c just use nil (i think)
postmodern
@postmodern:matrix.org
[m]
@asterite: but I guess the linux io_uring stuff requires raw syscall(2) access for a few IO syscalls from crystal's stdlib.
Alex Kampa
@alex-kampa
@naqvis Re listening to two separate tcp ports on spawned threads
" either you go with parallelism (i.e. via -Dmt_preview) or better go with two separate process each listening on its own port "
Fyi it actually works just by creating a channel and adding this to the end of the program:
  loop do
    puts channel.receive
  end
George Dietrich
@Blacksmoke16
@maxfierke Any objection to making a PR for maxfierke/crystal@fad7c79 ?
Ali Naqvi
@naqvis
@alex-kampa I think we are talking about two different concepts here. Fiber is not a OS Thread. Crystal default behavior without enabling that preview_mt is Single threaded model. All Fibers are run inside a single thread, so if you have a Fiber which run in a tight loop will starve all other Fibers to execute
4 replies
Thore Bödecker
@foxxx0
hi, I have a small applications where the main loop receives status-updates from a bunch of threads over a common communication channel. is there way to "collect" these updates in batches combined with a deadline? I.e. on a Channel#receive it will collect further updates (over the same Channel) for something like 50-100ms and after that timestamp then do something, even if no further update occured within the timespan. Is that possible? if yes: how would i achieve that?
Lance Dillon
@riffraff169
i kind of want to test the incremental bootstrap build, just to see what it is like
didactic-drunk
@didactic-drunk
@foxxx0
# Group by up to 1000 records flushing every 50ms
orm_record_channel.parallel.batch(1000, flush_interval: 0.05, flush_empty: true).run |batch|
  ORM.transaction { batch.each &.save }
end.wait
j8r
@jrei:matrix.org
[m]
what do you mean by starving - never being executed again?
that's a point of multi-threading, not blocking other operations - unless explicitly wanted
Alex Kampa
@alex-kampa
  a = ["string", 13, 787.to_i64]
  puts typeof(a[0]) #=> (Int32 | Int64 | String)
Why does this not give me String
Kaia Leahy
@tenebrousedge
because you're not using a Tuple
Arrays are variable sized, any element can be any of the types within the array
Tuples are fixed size and work like you are expecting with regards to types
Alex Kampa
@alex-kampa
Sure, but every individual element has its own definite type at any given time.
George Dietrich
@Blacksmoke16
The compiler isn't able to prove that
Kaia Leahy
@tenebrousedge
that's true of any union type
Alex Kampa
@alex-kampa
Ok so at runtime I want to do something if an element is a string, and something else if it is a number. Are you saying I need to convert the array into a tuple? Or is there another way?
Kaia Leahy
@tenebrousedge
use a case statement
and think about whether you really want an array with that union type in the first place
Alex Kampa
@alex-kampa
@tenebrousedge - re case statement - ok but case what?
Kaia Leahy
@tenebrousedge
case foo; when Int32 then do_stuff; when String then do_other_stuff
George Dietrich
@Blacksmoke16
a[0] specifically
Alex Kampa
@alex-kampa
Ok thanks that works - I was trying with typeof(a[0]) == "String" which didn't work.
Alex Kampa
@alex-kampa
Anyway, the function I was actually looking for was ".is_a?" - had forgotten about it - but the case construction which uses is_a? implicitly is indeed more elegant
Thanks again @tenebrousedge and @Blacksmoke16 !
George Dietrich
@Blacksmoke16
can also use case/in
which wouldn't compile if you introduced a fourth type into the union
dumbmahreeo
@dumbmahreeo:matrix.org
[m]
Hi, does anyone know if there are any plans of implementing preemption? Right now I don't trust Crystal for building backend as fibers can starve each other
George Dietrich
@Blacksmoke16
could prob code it to do that, nothing built in atm tho
dumbmahreeo
@dumbmahreeo:matrix.org
[m]

Already read #1454 but it's from 2017 and seems like the problem simply hasn't been addressed later.

PS: Sorry for the weird stuff, I'm new to matrix