-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add chan_send_(int|double|buf), chan_recv_(int|double|buf). #8
Conversation
Best way maybe include chan_type in chan_t and validate with CHAN_TYPE_INT/CHAN_TYPE_DOUBLE/etc . |
Can you explain what you mean by that? |
|
||
int chan_send_int(chan_t* chan, int data) | ||
{ | ||
int* wrapped = malloc(sizeof(int)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably check if wrapped == NULL
just to be completely safe.
int* wrapped = malloc(sizeof(int));
if (!wrapped)
{
return -1;
}
go's chan is a typed as specified. |
Done |
I'm not sure how you would implement typed channels. I think the typed
|
For example: raw_chan = chan_init(0); This chan doesn't check a type for sending type.
This chan check a type for sending type. |
I see what you mean. Enforcing the type might be important since if you have multiple producers sending different data types, you don't know how to receive them. Maybe typedef int chan_type;
#define CHAN_RAW 0
#define CHAN_INT 1
#define CHAN_DOUBLE 2
chan_t* chan_init(size_t capacity, chan_type type); |
Yes, I'm thinking so. |
I will merge this and the type checking can be added later. |
Add chan_send_(int|double|buf), chan_recv_(int|double|buf).
Related issue #7
Sorry I'm not native specker. I may add mis-spelling or broken phrase. So I didn't write comment.