From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id C9B201F87F for ; Tue, 20 Nov 2018 08:44:13 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D49F6120EF4; Tue, 20 Nov 2018 17:44:11 +0900 (JST) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by neon.ruby-lang.org (Postfix) with ESMTPS id E6CA2120EBE for ; Tue, 20 Nov 2018 17:44:08 +0900 (JST) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 140EE1F87F; Tue, 20 Nov 2018 08:44:07 +0000 (UTC) Date: Tue, 20 Nov 2018 08:44:06 +0000 From: Eric Wong To: ruby-core@ruby-lang.org Message-ID: <20181120084406.kcipybgonhzequ46@dcvr> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-ML-Name: ruby-core X-Mail-Count: 89900 Subject: [ruby-core:89900] Thread::Light patch against r65832 X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" > https://bugs.ruby-lang.org/issues/13618 Updated pull request against r65832 with new name: "Thread::Light" The following changes since commit 8d9a9aab67d6d517995532737a37379c20dc7f76: thread_pthread.c (rb_reserved_fd_p): false-positive on negative FD (2018-11-20 07:27:28 +0000) are available in the Git repository at: https://80x24.org/ruby.git thread-light-r65832 for you to fetch changes up to d03da60f2ef9cf176744168bf2c12b7ab948879c: Thread::Light: green threads implemented using fibers (2018-11-20 08:20:48 +00 00) ---------------------------------------------------------------- Eric Wong (2): unify sync_waiter, waitpid_state, waiting_fd w/ rb_sched_waiter Thread::Light: green threads implemented using fibers 2-patch series (squashed history because there were many names for this feature (auto-fiber/Thriber/Threadlet/Thread::Coro) and now finally Thread::Light: https://80x24.org/spew/20181120083413.43523-2-e@80x24.org/raw https://80x24.org/spew/20181120083413.43523-3-e@80x24.org/raw This adds following scheduling points: C-API scheduling points: * rb_wait_for_single_fd * rb_thread_fd_select * rb_waitpid (SIGCHLD platforms only) These three functions are used by many Ruby methods, which all now become scheduling points. additional Ruby API scheduling points: * Kernel#sleep * Thread.pass * IO.copy_stream * {Queue,SizedQueue}#{push,pop} FIXME: the "select"-based implementation still has some missed events problems. Fortunately, relevant production systems use kqueue or epoll which have no known problems at the moment (tested FreeBSD 11.2 and Linux 4.19.2) Thread::Light local storage is implemented (#[], #[]=, #fetch, #key?, and #keys) just like normal Fibers. Thread::Light#stop? and Thread::Light#status are analogous to their regular Thread methods. Thread::Light#run and Thread::Light#wakeup are supported for waking up from Kernel#sleep. Mutex and ConditionVariable are NOT scheduling points for Thread::Light switching; however they may process signal handling and handle I/O dispatch for other native threads. Thread::Light.list does not exist, yet (needed?). I don't know what to do about Thread#raise/Thread#kill...