00:44:55  * saghuljoined
00:48:06  * qardquit (Quit: My MacBook has gone to sleep. ZZZzzz…)
00:49:01  * saghulquit (Ping timeout: 240 seconds)
01:02:20  * happy-dudequit (Quit: Connection closed for inactivity)
01:06:34  * qardjoined
04:42:25  * saghuljoined
04:46:27  * saghulquit (Ping timeout: 240 seconds)
05:50:20  * qardquit (Quit: My MacBook has gone to sleep. ZZZzzz…)
06:00:17  * qardjoined
06:02:32  * qardquit (Client Quit)
07:29:20  * rendarjoined
08:23:32  * saghuljoined
09:01:06  * saghulquit (Quit: My MacBook has gone to sleep. ZZZzzz…)
09:05:50  * saghuljoined
09:53:35  * saghulquit (Quit: My MacBook has gone to sleep. ZZZzzz…)
09:58:35  * saghuljoined
10:25:11  * mylesborinsquit (Quit: farewell for now)
10:25:42  * mylesborinsjoined
10:34:52  * saghulquit (Quit: My MacBook has gone to sleep. ZZZzzz…)
10:54:53  * saghuljoined
11:03:57  * qardjoined
11:08:28  * qardquit (Ping timeout: 240 seconds)
11:13:04  * saghulquit (Quit: My MacBook has gone to sleep. ZZZzzz…)
12:03:27  * AtumTjoined
13:35:41  * saghuljoined
14:49:35  * happy-dudejoined
15:38:31  * joocain2quit (Read error: Connection reset by peer)
15:39:27  * joocain2joined
16:22:59  * qardjoined
16:28:56  * Fishrock123joined
17:01:09  * saghulquit (Ping timeout: 246 seconds)
17:28:31  * soniex2joined
17:29:14  <soniex2>how do I create sockets in thread A and pass them to threads B, C, D, ...?
17:31:26  <soniex2>a la bind(s, ...) c = accept(s, ...) sendToThread(c)
17:33:33  <soniex2>technically createThread(c) but w/e
17:52:51  <soniex2>and yes, I do need multiple threads. this is all the bloody thing'll be doing, and it's running on a Pi. so to use the full CPU power I need the threads.
17:53:26  <soniex2>(has anyone used libuv in embedded systems?)
18:03:20  * Fishrock123quit (Remote host closed the connection)
18:03:58  * Fishrock123joined
18:08:00  * Fishrock123quit (Ping timeout: 246 seconds)
18:14:07  * Fishrock123joined
18:24:01  <soniex2>hello?
18:24:12  <refack>soniex2: hi.
18:25:11  <soniex2>any idea how I can make this thing work?
18:25:17  <refack>AFAIK libuv is used extensively in PIs, mostly via nodejs
18:25:57  <soniex2>yes let's put a 100MB-at-idle VM on a Pi
18:26:19  <soniex2>sorry but I'd rather do this in C
18:26:33  <refack>the main libuv loop is single threaded (only the thread holding the loop is guaranteed safety)
18:27:03  <refack>Agreed, just referring to in the field usage
18:27:23  <soniex2>my current blocking C code does s=socket(...) bind(s,...) loop{c=accept(s,...) sendToThread(c)}
18:28:01  <refack>You could harness libuv's thread pool - http://docs.libuv.org/en/v1.x/threadpool.html
18:28:58  <soniex2>then it seems to call getpeername and getnameinfo in the thread, I'm not sure what those do
18:29:06  <refack>so if your thread code does not interact with the loop, and you guarantee exclusivity on `c`, there should be no problem AFAICT
18:29:55  <soniex2>oh yeah I also need to interact with mysql somehow
18:33:14  <refack>So, what node does for this cases is multi-proc - start NumOfCores proc and pass the sockets in a round robin, i.e. use the patterns of https://nodejs.org/api/cluster.html but just in C
18:34:21  <refack>You could alternatively guard exclusivity for all interactions with the loop
18:34:54  <refack>But it seems like your case fits well with the reactive model
18:36:33  <soniex2>how do I send sockets to threads like I'm currently doing, but non-blocking?
18:36:39  <refack>1. Main thread binds listing socket
18:36:39  <refack>2. On libuv accept - uv_queue_work
18:36:39  <refack>3. thread adds MySql callbacks to the loop (or blocks)
18:37:11  <soniex2>why uv_queue_work?
18:37:29  <refack>let libuv manage your thread pool
18:38:06  <soniex2>no that'll cause issues with mysql
18:41:57  <refack>so you can use http://docs.libuv.org/en/v1.x/stream.html#c.uv_accept and use the callback to `sendToThread`
18:42:37  <refack>uv_accept is non-bloking
18:52:44  <soniex2>but what do I send to the thread and what do I use in the thread?
18:55:07  <soniex2>(because I can't find that on docs or internet search)
18:55:19  <refack>the callback receives a uv_stream_t which has http://docs.libuv.org/en/v1.x/stream.html#c.uv_connect_t.handle which is
18:55:22  <refack>the socket
18:57:06  <qard>Um...nodejs is nowhere near 100MB at idle. A basic http server for me idles at 9MB.
18:57:08  <refack>you get it's FD with http://docs.libuv.org/en/v1.x/handle.html#c.uv_fileno
18:58:11  <qard>Still could probably be lighter in pure C, but 100MB is hyperbole.
19:00:15  <refack>soniex2: actually if all you want is nonblocking accept, might be simpler to call epoll directly
19:01:08  <soniex2>I want nonblocking everything but I also wanna send the socket to another thread
19:01:35  <refack>libuv's value proposition is cross-platform-uniform API for all blocking syscalls like FS, tty, and timers
19:01:40  <refack>Ahh
19:02:09  <refack>then use uv_accept and unwrap the socket
19:04:40  * soniex2_joined
19:05:05  <soniex2_>ok so if I unwrap the socket how do I wrap it back so I can actually use it?
19:05:55  * soniex2quit (Ping timeout: 260 seconds)
19:05:58  <soniex2_>also can I tell libuv to do its best to read N bytes and only call my cb if it read N bytes or something went wrong?
19:06:19  <refack>yes, using the stream API
19:09:02  * rendarquit (Quit: std::lower_bound + std::less_equal *works* with a vector without duplicates!)
19:10:00  <refack>soniex2_:
19:10:32  <refack>the unwrapped socket is it's FD you can call `read` on it as usual
19:13:37  <refack>This might help - https://github.com/Ryannnnnnn/libuv-httpserver
19:16:04  <refack>or https://github.com/litesync/uv_callback
20:37:01  * Fishrock123quit (Remote host closed the connection)
20:37:17  * Fishrock123joined
20:37:47  * Fishrock123quit (Remote host closed the connection)
21:03:44  * Fishrock123joined
21:07:15  * soniex2_quit (Ping timeout: 260 seconds)
22:46:38  * Fishrock123quit (Remote host closed the connection)
22:46:53  * Fishrock123joined
22:47:24  * Fishrock123quit (Remote host closed the connection)
23:21:56  * Fishrock123joined
23:28:57  * tumdedumquit (Ping timeout: 240 seconds)
23:29:37  * tumdedumjoined
23:59:30  * happy-dudequit (Quit: Connection closed for inactivity)