Chan

Languages and libraries

concurrency library

SHOW HN2014

150points
44comments
#165of 2,272 in 2014
Top 8%of 2014 by points

How HN took it

MixedNo clear lean

3 positive, 7 neutral or asking, 0 mixed, 7 critical, out of 17 comments about the project. Thread score -0.09.

Execution: 0 for, 7 againstDesign: 1 for, 0 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Nice, useful for C and Go programmers

    From 2 comments
    • This is pretty awesome. I do a lot of Go and C and this just might come in handy. Thanks for sharing!
      vhost- on HN
    • Very nice. Any chance of Boost licensing it?
      WalterBright on HN
  • Clever function naming

    From 1 comment
    • Pretty nifty. I like the names of the functions chan_can_recv() and chan_can_send(). Made me think think of the old cooking show "Yan Can Cook."
      chi42 on HN

Objections

  • Relies on pthreads, so not pure C

    From 2 comments
    • > #include <pthread.h> That is not "pure C". "pthread.h" (POSIX threads) is not part of the C language standard, it is a system-specific header commonly found on UNIX systems.…
      copx on HN
    • I agree, OP could have used the C11 feature, <threads.h>
      readerrrr on HN
  • Memory leaks and missing mutex/cond cleanup

    From 3 comments
    • The struct is currently storing a pointer to the mutex (which was allocated with malloc). The call to pthread_mutex_destroy does not free that memory. Valgrind is your friend :)…
      pmahoney on HN
    • I think you need to add ``` pthread_cond_destroy(&chan->m_cond); ``` After https://github.com/tylertreat/chan/blob/master/src/chan.c#L136
      BrandonM on HN
    • You shouldn't allocate heap space for a pointer in blocking_pipe_read. Also, it looks like you're leaking it in the else branch. Just allocate a pointer on the stack, read into…
      clarry on HN
  • Struct design: mutexes should be embedded, not malloc'd

    From 2 comments
    • Good stuff, thanks for sharing. Random comments based on a quick glance through the code if I may. ``` chan_t* chan_init(int capacity); ``` should be "size_t capacity", since…
      eps on HN
    • What eps means is that, currently you have a pointer to a mutex in your struct: ``` struct chan_t { pthread_mutex_t* m_mu;... } ``` And initialize it like so: ```…
      millstone on HN

Requests

  • Use size_t for capacity

    From 1 comment
    • Good stuff, thanks for sharing. Random comments based on a quick glance through the code if I may. ``` chan_t* chan_init(int capacity); ``` should be "size_t capacity", since…
      eps on HN
  • Boost-style licensing

    From 1 comment

Questions

  • How does it compare to ZeroMQ inproc sockets?

    From 1 comment
    • How does this compare to using ZeroMQ inproc sockets?
      SeoxyS on HN

Alternatives named

  • libtask by Russ Cox

    From 1 comment
    • Libtask[1] by Russ Cox (one of the creators of Go) may provide some inspiration. It implements channels but uses coroutines instead of threading. As a consequence it has some…
      kersny on HN
  • Plan 9 thread library

    From 2 comments
    • The circle is now complete... Plan 9 from user space implementation of channels. http://swtch.com/usr/local/plan9/include/thread.h
      arjovr on HN
    • http://plan9.bell-labs.com/magic/man2html/2/thread
      mseepgood on HN
  • libco

    From 1 comment
    • Just a forewarning: that library, like most C cooperative threading libraries, is using ucontext. ucontext is unbearably slow, to the point where it's just as fast to use real…
      byuu on HN
  • ZeroMQ inproc sockets

    From 1 comment
    • How does this compare to using ZeroMQ inproc sockets?
      SeoxyS on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/8244815)