JanetDocsSourcePlaygroundI'm feeling luckyCommunityGitHub sign in

fiber/new

core-api


    cfunction
    src/core/fiber.c on line 481, column 1

    (fiber/new func &opt sigmask env)

    Create a new fiber with function body func. Can optionally take a 
    set of signals `sigmask` to capture from child fibers, and an 
    environment table `env`. The mask is specified as a keyword where 
    each character is used to indicate a signal to block. If the ev 
    module is enabled, and this fiber is used as an argument to 
    `ev/go`, these "blocked" signals will result in messages being sent 
    to the supervisor channel. The default sigmask is :y. For example,

        (fiber/new myfun :e123)
        
    blocks error signals and user signals 1, 2 and 3. The signals are 
    as follows:

    * :a - block all signals
    * :d - block debug signals
    * :e - block error signals
    * :t - block termination signals: error + user[0-4]
    * :u - block user signals
    * :y - block yield signals
    * :w - block await signals (user9)
    * :r - block interrupt signals (user8)
    * :0-9 - block a specific user signal

    The sigmask argument also can take environment flags. If any 
    mutually exclusive flags are present, the last flag takes 
    precedence.

    * :i - inherit the environment from the current fiber
    * :p - the environment table's prototype is the current environment 
      table


See also:coro1 exampleSign in to add an example
Loading...
(map inc
     (fiber/new |(each x (range 3)
                   (yield x))))
# => @[1 2 3]
sogaiuPlayground