Comments (6)
👍 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.
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.
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.
Based on discussion in this PR, I think we will look at making channels "typed."
from chan.
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.
Agreed. We will have to add new types for each users want.
from chan.
Related Issues (16)
- memory not freed HOT 10
- deadlock HOT 1
- deadlock2 HOT 2
- Proposal for Removing blocking_pipe_t HOT 6
- Proposol: Removing unecessary malloc/free in queue_t HOT 1
- Clibs package HOT 5
- Missing speed test HOT 8
- change implementation language to C HOT 2
- chan_recv can receive duplicate sent values
- optional size param for send/recv
- Will select block if chan_can_recv first true then false?
- Does this facilitate C - Go communication? HOT 4
- problem of threads?
- C2x feature proposal?
- Add support for blocking selects
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chan.