Giter Club home page Giter Club logo

Comments (6)

tylertreat avatar tylertreat commented on September 16, 2024

👍 Yes, this would be a good addition to the API. I think send would look something like this:

int chan_send_int(chan_t* chan, int data)
{
    int* wrapped = malloc(sizeof(int));
    *wrapped = data;

    int success = chan_send(chan, wrapped);
    if (success != 0)
    {
        free(wrapped);
    }

    return success;
}

What I'm not sure about is how recv should work. chan_recv currently takes a pointer that it sets so it can return an int to indicate success. I'm thinking the other recv functions should work similarly.

Thoughts?

from chan.

mattn avatar mattn commented on September 16, 2024

Right. Or how about this? This is way to hide freeing code.

int n;
char buf[256];
chan_recv_int(c, &n);
chan_recv_string(c, buf, sizeof(buf));

from chan.

tylertreat avatar tylertreat commented on September 16, 2024

I think this looks good.
On Sep 3, 2014 11:22 PM, "mattn" [email protected] wrote:

Right. Or how about this? This is way to hide freeing code.

int n;char buf[256];chan_recv_int(c, &n);chan_recv_string(c, buf, sizeof(buf));


Reply to this email directly or view it on GitHub
#7 (comment).

from chan.

tylertreat avatar tylertreat commented on September 16, 2024

Based on discussion in this PR, I think we will look at making channels "typed."

from chan.

tylertreat avatar tylertreat commented on September 16, 2024

So, thinking more about typed channels, I'm wondering how useful it would actually be to store the type on chan_t? If typed channels is the way we want to go, it seems like we would need to define a chan_t for each type: int, double, char, etc.

from chan.

mattn avatar mattn commented on September 16, 2024

Agreed. We will have to add new types for each users want.

from chan.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.