NAME
Glib::Ex::SourceIds -- hold Glib main loop source IDs
SYNOPSIS
use Glib::Ex::SourceIds;
my $ids = Glib::Ex::SourceIds->new
(Glib::Timeout->add (1000, \&do_timer),
Glib::Idle->add (\&do_idle));
# removed when ids object destroyed
$ids = undef;
DESCRIPTION
Glib::Ex::SourceIds
holds a set of Glib main loop source IDs. When the SourceIds is destroyed it removes those IDs.
This is designed to make life easier when keeping sources installed for a limited period, such as an IO watch while communicating on a socket, or a timeout on an action. Often such things will be associated with a Glib::Object
(or just a Perl object), though they don't have to be.
FUNCTIONS
$sobj = Glib::Ex::SourceIds->new ($id,$id,...)
-
Create and return a SourceIds object holding the given
$id
main loop source IDs (integers).SourceIds doesn't install sources. You do that with
Glib::Timeout->add
,Glib::IO->add_watch
andGlib::Idle->add
in the usual ways and all the various options, then pass the resulting ID to SourceIds to look after. Eg.my $ids = Glib::Ex::SourceIds->new (Glib::Timeout->add (1000, \&do_timer));
You can hold any number of IDs in a SourceIds object. Generally if you want things installed and removed at different points in the program then you'll use separate SourceIds objects for each (or each group).
$ids->remove()
-
Remove the source IDs held in
$ids
from the main loop, usingGlib::Source->remove
, if not already removed (for instance by a "false" return from the handler code). This remove is done when$ids
is garbage collected, but you can do it explicitly sooner if desired.
SEE ALSO
Glib::MainLoop, Glib::Ex::SignalIds
HOME PAGE
http://www.geocities.com/user42_kevin/glib-ex-objectbits/index.html
LICENSE
Copyright 2008, 2009 Kevin Ryde
Glib-Ex-ObjectBits is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Glib-Ex-ObjectBits is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Glib-Ex-ObjectBits. If not, see http://www.gnu.org/licenses/.