Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
BUNDLE(3)		   libdill Library Functions		     BUNDLE(3)

NAME
       bundle -	create an empty	coroutine bundle

SYNOPSIS
	      #include <libdill.h>

	      int bundle(void);

DESCRIPTION
       Coroutines are always running in	bundles.  Even a single	coroutine cre-
       ated by go gets its own bundle.	A bundle is a lifetime control	mecha-
       nism.   When  it	 is  closed, all coroutines within the bundle are can-
       celed.

       This function creates an	empty bundle.  Coroutines can be added to  the
       bundle using the	bundle_go and bundle_go_mem functions.

       To wait until coroutines	in the bundle finish use bundle_wait function.

       When  hclose() is called	on the bundle, all the coroutines contained in
       the bundle will be canceled.  In	other words, all  the  blocking	 func-
       tions  within the coroutine will	start failing with an ECANCELED	error.
       The hclose() function itself won't exit until all the coroutines	in the
       bundle exit.

RETURN VALUE
       In  case	 of  success  the  function returns handle of the newly	create
       coroutine bundle.  In case of error it returns -1 and sets errno	to one
       of the values below.

ERRORS
       o EMFILE: The maximum number of file descriptors	in the process are al-
	 ready open.

       o ENFILE: The maximum number of file descriptors	in the system are  al-
	 ready open.

       o ENOMEM: Not enough memory.

EXAMPLE
	      int b = bundle();
	      bundle_go(b, worker());
	      bundle_go(b, worker());
	      bundle_go(b, worker());
	      /* Give wrokers 1	second to finish. */
	      bundle_wait(b, now() + 1000);
	      /* Cancel	any remaining workers. */
	      hclose(b);

SEE ALSO
       bundle_go(3)   bundle_go_mem(3)	 bundle_mem(3)	 bundle_wait(3)	 go(3)
       go_mem(3) hclose(3) yield(3)

libdill								     BUNDLE(3)

NAME | SYNOPSIS | DESCRIPTION | RETURN VALUE | ERRORS | EXAMPLE | SEE ALSO

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=bundle&sektion=3&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help