.TH "shevek::closure" 3 "Wed Jul 9 2014" "libshevek" \" -*- nroff -*- .ad l .nh .SH NAME shevek::closure \- .PP Block and resume without blocking the main loop\&. .SH SYNOPSIS .br .PP .PP \fC#include \fP .PP Inherits \fBshevek::refbase\fP\&. .SS "Public Member Functions" .in +1c .ti -1c .RI "bool \fBempty\fP () const " .br .RI "\fICheck if the closure is empty\&. \fP" .ti -1c .RI "void \fBset_function\fP (sigc::slot0< void > func, bool run=true, sigc::slot0< void > cb=sigc::slot0< void >())" .br .RI "\fISet running function on an empty closure\&. \fP" .ti -1c .RI "\fB~closure\fP ()" .br .RI "\fIDestructor\&. \fP" .ti -1c .RI "void \fBwake\fP ()" .br .RI "\fIContinue running the closure\&. \fP" .in -1c .SS "Static Public Member Functions" .in +1c .ti -1c .RI "static Glib::RefPtr< \fBclosure\fP > \fBcreate\fP ()" .br .RI "\fICreate a new closure\&. \fP" .ti -1c .RI "static void \fBblock\fP ()" .br .RI "\fISleep, returning control to the caller until awoken\&. \fP" .in -1c .SS "Additional Inherited Members" .SH "Detailed Description" .PP Block and resume without blocking the main loop\&. Closures allow blocking and resuming the main loop\&. They are implemented with threads, which means that they don't work well with multi-threaded programs\&. .PP If a function wants to be able to block using a closure, it must be called using closure()\&. It (or any function it calls) can then suspend by calling \fBclosure::block()\fP\&. It can be awoken again by calling \fBclosure::wake()\fP on the closure object\&. .SH "Member Function Documentation" .PP .SS "static void shevek::closure::block ()\fC [static]\fP" .PP Sleep, returning control to the caller until awoken\&. This function puts the current closure to sleep\&. It will continue to run when awoken with \fBwake()\fP\&. It can also be destroyed\&. This function uses a global variable to know which is the current closure, so it can be called without an object, as \fBclosure::block\fP (); \&. .SS "static Glib::RefPtr<\fBclosure\fP> shevek::closure::create ()\fC [inline]\fP, \fC [static]\fP" .PP Create a new closure\&. Create a new closure\&. It will be empty initially\&. .SS "bool shevek::closure::empty () const\fC [inline]\fP" .PP Check if the closure is empty\&. Check if the closure is empty\&. If it is, \fBset_function()\fP can be called\&. .SS "void shevek::closure::set_function (sigc::slot0< void >func, boolrun = \fCtrue\fP, sigc::slot0< void >cb = \fCsigc::slot0< void >()\fP)" .PP Set running function on an empty closure\&. Set running function\&. The closure must be empty when this is called\&. When the function exits, the closure returns to the empty state, and the callback is called, if given\&. .SS "void shevek::closure::wake ()" .PP Continue running the closure\&. Wake a closure\&. It is an error to wake a closure which isn't blocking (in particular also the currently running closure)\&. .SH "Author" .PP Generated automatically by Doxygen for libshevek from the source code\&.