Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    jpcooper
    @jpcooper
    I haven't yet
    Josh Suereth
    @jsuereth
    I can push a 2.0.1 with that change though, it won't be binary incompatible
    or a 2.1, I mean
    jpcooper
    @jpcooper
    which version should I fork?
    Josh Suereth
    @jsuereth
    2.0
    err master
    If you want we can release it on 1.x too
    Yang, Bo
    @Atry
    Hello @jsuereth , could you review my Pull Request jsuereth/scala-arm#46, please?
    jpcooper
    @jpcooper
    @jsuereth I'll make a PR to master either this evening or on Saturday
    @Atry nice
    Josh Suereth
    @jsuereth
    @Atry nice! Comments in line, I can merge when I'm not mobile
    Josh Suereth
    @jsuereth
    /all if someone could check my threading here: jsuereth/scala-arm#47
    Also, I'm a bit nervous about shared resources now that I've had a chance to think 'em through. Specifically not sure how to handle 'close after exception' or whether or not we need to notify ALL shared users of failure and "abandon" their usage
    Yang, Bo
    @Atry

    I find that you removed the lock in close function, which is good. I did not realize that the lock could be replace by a CAS.

    But I wonder if we can still use synchronized for open, instead of a spin lock, as JRE's synchronized also performs spin lock for a short time.

    Josh Suereth
    @jsuereth
    Yeah, synhronized may actually be the right thing to do here. we're not going to be talking between threads THAT often I think....
    But We still need to clean u pthe error handlign. I'll do that with synchronized and we can evaluate lockless later
    jpcooper
    @jpcooper
    @jsuereth Have you ever needed to work with a few hundred resource simultaneously? I've written a function that takes T[ManagedResource[U]] to ManagedResource[T[U]] for T <: Traversable. However, this method relies on foldLeft and flatMap. This leads to StackOverflowError if the input is too long. Do you know of any better way to do this?
    I was considering writing case class ManagedResourceSequence[a](resource: Seq[a]). Do you see any problems with this?
    jpcooper
    @jpcooper
    Well, one problem is that ManagedResource doesn't expose the resource
    jpcooper
    @jpcooper
    I think what we're actually looking for is making ManagedResource Applicative without flatMap
    Josh Suereth
    @jsuereth_twitter
    yeah
    SO
    1. Using flatMap is "ok" I think, if we trampoline
    1. I think having an applicative + traverse would be really nice. What do you need to make that happen?
    I'm thinking of non/cats extension
    jpcooper
    @jpcooper
    The problem right now as that ManagedResource doesn't have an open method like AbstractManagedResource does
    Josh Suereth
    @jsuereth_twitter
    right, so you need to assume things about it.....
    is "zip" enough on managed resource?
    jpcooper
    @jpcooper
    Yes, but how would it be implemented?
    Josh Suereth
    @jsuereth_twitter
    it already is?
    jpcooper
    @jpcooper
    without flatMap?
    I don't see zip in ManagedResource
    I guess I'm looking for and without flatMap
    jpcooper
    @jpcooper
    @jsuereth Doesn't that still involve a big stack, or am I missing something?
    This is what I'm doing:
    def sequenceManagedResources[R, T[X] <: TraversableOnce[X]](managedResources: T[ManagedResource[R]])(implicit canBuildFrom: CanBuildFrom[T[ManagedResource[R]], R, T[R]]): ManagedResource[T[R]] = {
        val initialBuilderResource = unitManaged(canBuildFrom(managedResources))
    
        val finalManagedBuilder = managedResources.foldLeft(initialBuilderResource) { case (builderResource, managedR) ⇒
          builderResource.flatMap { builder ⇒
            managedR.map(r ⇒ builder += r)
          }
        }
    
        finalManagedBuilder.map(_.result())
      }
    def unitManaged[T](value: => T): ManagedResource[T] = {
        managed(()).map(_ ⇒ value)
      }
    Josh Suereth
    @jsuereth
    hey, sorry
    they may both have that issue....
    for popping the stack, we'd need to use an alternative mechanism for this. I have an idea for how to do it, need to experiment
    jpcooper
    @jpcooper
    @jsuereth I suppose we would need to allow one ManagedResource to control another ManagedResource's resource
    jpcooper
    @jpcooper
    @jsuereth I'm going to give it a go with continuations
    jpcooper
    @jpcooper
    Sorry for the mess. I realise the implementation of and in my version of scala-arm uses .reflect. Why was this removed in the latest version?
    Josh Suereth
    @jsuereth_twitter
    because CPS transformed were removed from being supported in scala :(
    I like continuations
    SO, what we should do here
    is basically optimise for the "AbstractMangedResource" case
    jpcooper
    @jpcooper
    @jsuereth Do you mean they'll be removed in 2.12?
    Josh Suereth
    @jsuereth_twitter
    yeah