2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <boost/cstdint.hpp>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/thread.hpp>
30 #include "extension.h"
35 /// This namespace is for all the Cygnal specific classes not used by
36 /// anything else in Gnash.
39 /// \class cygnal::Cygnal
44 typedef Handler::cygnal_init_t (*initentry_t
)();
51 gnash::Network::protocols_supported_e protocol
;
52 std::vector
<std::string
> supported
;
54 static Cygnal
& getDefaultInstance();
58 bool loadPeersFile(const std::string
&filespec
);
61 void probePeers(peer_t
&peer
);
62 void probePeers(boost::shared_ptr
<peer_t
> peer
);
63 void probePeers(std::vector
<boost::shared_ptr
<peer_t
> > &peers
);
65 void addHandler(const std::string
&path
, boost::shared_ptr
<Handler
> x
) {
69 boost::shared_ptr
<Handler
> findHandler(const std::string
&path
);
70 void removeHandler(const std::string
&path
);
72 std::vector
<boost::shared_ptr
<peer_t
> > & getActive() { return _active_peers
; };
77 void addPeer(boost::shared_ptr
<peer_t
> x
) {
81 std::vector
<boost::shared_ptr
<peer_t
> > _peers
;
82 std::vector
<boost::shared_ptr
<peer_t
> > _active_peers
;
83 std::map
<std::string
, boost::shared_ptr
<Handler
> > _handlers
;
87 /// \class cygnal::ThreadCounter of threads currently
88 /// active. This is primarily so the counter can be wrapped with a
89 /// mutex to be thread safe, as threads delete themseleves.
94 ThreadCounter() : _tids(0) {};
95 void increment() { boost::mutex::scoped_lock
lk(_tid_mutex
); ++_tids
; };
96 void decrement() { boost::mutex::scoped_lock
lk(_tid_mutex
); --_tids
; };
97 int num_of_tids() { return _tids
; };
99 boost::mutex _tid_mutex
;
101 boost::thread _tid_handle
;
104 // End of gnash namespace
113 // indent-tabs-mode: t