C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/????????????????????????????????2?????zh-cnMon, 20 Jan 2020 19:16:45 GMTMon, 20 Jan 2020 19:16:45 GMT60C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2019/08/01/GC_System_for_Cpp.htmlKhanKhanThu, 01 Aug 2019 02:57:00 GMThttp://www.598club.com/Khan/archive/2019/08/01/GC_System_for_Cpp.htmlhttp://www.598club.com/Khan/comments/216620.htmlhttp://www.598club.com/Khan/archive/2019/08/01/GC_System_for_Cpp.html#Feedback0http://www.598club.com/Khan/comments/commentRss/216620.htmlhttp://www.598club.com/Khan/services/trackbacks/216620.html# ?? C++ ??-??????????a??????????????? gc ?3????
[?????](http://blog.codingnow.com/2010/02/cpp_gc.html)
???????3??? engine ????????a?????? C++ ????????????? QT ????????engine ???o???????o? C ?????????????????o?????o?o? lua ???????????1??1?????????????????1?????? lua ??? gc ?3?????????3?o????????????????????????????????????????????????? ??o lua ???? C ??1????????-?????????????? ???
??????????????-?'??????? C++ ??-??????????????????1???????????C++ ?2????????????? gc ?????????????1?????????????????a gc ?o???????????1????o?????????????????'??????????????1'????????????????????o????????????3????????????????????o??????a??'????????? gc ?????????????? 200 ??????????????????'????????????? blog ?????
???o??????????o????????????????????o??????????'????????????????????????????????1?????????????????'?????????????????????????????o???o??????????
|?????????|??????a`????????`??? `gc?3????`???????????3`????????`?????1??????3???`??a????????`???????????????????????3???`????????`??????a??????1??????????????3??'????????????
????????3????????????? template ???????????????a??????-?3??3?????????????????????????|??????|??????o? C++ ???????????????'??????????'???“?????3”????????3?1????????????????o???????
????????????????????????????|??????1??????oo????'?2??????????????????3??o????????????o????????????? COM ??????????? ABI ????????????????? C++ ?-????o????????????o?????????????????
?????????????????????|?????????oo???????a?'???????
?????????3????????????3??????????????1????????????????oo????????????????????????????????3?o?????????1???1????????????????????o?????????????
???????|???????
 1 /* 
 2  * filename: i_gcobject.h 
 3  * Copyright (c) 2010 ,
 4  * Cloud Wu . All rights reserved. 
 5  * 
 6  * http://www.codingnow.com 
 7  * 
 8  * Use, modification and distribution are subject to the "New BSD License" 
 9  * as listed at . 
10  */ 
11   
12 #ifndef interfacce_gcobject_h 
13 #define interfacce_gcobject_h 
14 
15 #define interface struct 
16 
17 interface i_gcobject { 
18     virtual ~i_gcobject() {} 
19 
20     virtual void touch() {} 
21 
22     virtual void mark() = 0 ; 
23     virtual void grab() = 0 ; 
24     virtual void release() = 0 ; 
25 
26     static void collect(); 
27 }; 
28 #endif

???????????? `gc???????????????`????????3 `i_gcobject` ??????????????a??1?3?:
* mark ?????????????a??1?????????????????????????1??????????? collect ?????????
* grab ????1??????????????a????????o root ?????1??? gcobject ??????
* release ????1???? root ????????????
??|?????? touch ??????????1?3???? mark ????????????????????????1???-????????????????
mark ??1?3???????? touch ??1?3???-??????????|?????collect ??1?3??????????? root ??? mark ???
 1 /*  filename: i_gcholder.h
 2  *  Copyright (c) 2010 ,
 3  *      Cloud Wu . All rights reserved.
 4  *
 5  *      http://www.codingnow.com
 6  *
 7  *  Use, modification and distribution are subject to the "New BSD License"
 8  *  as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
 9  */
10 
11 #ifndef interfacce_gcholder_h
12 #define interfacce_gcholder_h
13 
14 #include "i_gcobject.h"
15 
16 interface i_gcholder : virtual i_gcobject {
17   virtual void hold(i_gcobject *) = 0;
18   virtual void unhold(i_gcobject *) = 0;
19   
20   static i_gcholder * create();
21 };
22 #endif
`i_gcholder` ??o root ?????????????????? `hold` ??? `unhold` ??1?3????????????|?????1?????????? gcobject ???

 1 /*  filename: i_gcobject.h
 2  *  Copyright (c) 2010 ,
 3  *      Cloud Wu . All rights reserved.
 4  *
 5  *      http://www.codingnow.com
 6  *
 7  *  Use, modification and distribution are subject to the "New BSD License"
 8  *  as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
 9  */
10 
11 #ifndef interfacce_gcobject_h
12 #define interfacce_gcobject_h
13 #define interface struct
14 
15 interface i_gcobject {
16 
17   virtual ~i_gcobject() {}
18 
19   virtual void touch() {}
20 
21   virtual void mark() = 0 ;
22   virtual void grab() = 0 ;
23   virtual void release() = 0 ;
24 
25   static void collect();
26 };
27 #endif
 1 /*  filename: gcobject.h
 2  *  Copyright (c) 2010 ,
 3  *      Cloud Wu . All rights reserved.
 4  *
 5  *      http://www.codingnow.com
 6  *
 7  *  Use, modification and distribution are subject to the "New BSD License"
 8  *  as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
 9  */
10 
11 #ifndef gc_object_h
12 #define gc_object_h
13 
14 #include "i_gcobject.h"
15 
16 class gcobject : virtual i_gcobject {
17   bool marked;
18 
19 public:
20   gcobject();
21 
22   virtual void mark();
23   virtual void grab();
24   virtual void release();
25 
26   struct f_unmarked;
27 
28 };
29 #endif
30 ```
31 
32 ```c++
33 /*  filename: gcobject.cpp 
34  *  Copyright (c) 2010 ,
35  *      Cloud Wu . All rights reserved.
36  *
37  *      http://www.codingnow.com
38  *
39  *  Use, modification and distribution are subject to the "New BSD License"
40  *  as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
41  */
42 
43 #include "gcobject.h"
44 #include "i_gcholder.h"
45 #include <vector>
46 #include <algorithm>
47 
48 static bool gc_trigger;
49 static std::vector<gcobject *> gc_pool;
50 static i_gcholder * gc_root = i_gcholder::create();
51 
52 
53 struct gcobject::f_unmarked {
54   bool operator() (gcobject * value) {
55     bool unmarked = value->marked != gc_trigger;
56     if (unmarked) {
57       delete value;
58     }
59     return unmarked;
60   }
61 };
62 
63 gcobject::gcobject() : marked(!gc_trigger) {
64   gc_pool.push_back(this);
65 }
66 
67 void gcobject::mark() {
68   if (marked != gc_trigger) {
69     marked = gc_trigger;
70     touch();
71   }
72 }
73 
74 void gcobject::grab(){
75   gc_root->hold(this);
76 }
77 
78 void gcobject::release(){
79   gc_root->unhold(this);
80 }
81 
82 void i_gcobject::collect() {
83   gc_root->mark();
84   gc_pool.erase(remove_if(gc_pool.begin(), gc_pool.end() , gcobject::f_unmarked()), gc_pool.end());
85   gc_trigger = !gc_trigger;
86 }
gcobject ??o???????? gc ??????????????o? `mark` ???`grab`???`release` ??? `collect` ??1?3????
`mark` ?????????'????????? bool ?????????????????????a??????????o? `trigger` ????a?1??1??????3????????? `collect` ????????????????????
`grab` ??? `release` ???????????1????????? root ????????????????????????
`collect` ??????????? root ????? `mark` ????1?????????o??2???? `mark` ?????1????

 1 /*  filename: gcholder.cpp
 2  *  Copyright (c) 2010 ,
 3  *      Cloud Wu . All rights reserved.
 4  *
 5  *      http://www.codingnow.com
 6  *
 7  *  Use, modification and distribution are subject to the "New BSD License"
 8  *  as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
 9  */
10 
11 #include "i_gcholder.h"
12 #include "gcobject.h"
13 #include <vector>
14 #include <algorithm>
15 #include <cassert>
16 
17 class gcholder : public virtual i_gcholder, virtual gcobject {
18   std::vector<i_gcobject *> hold_set;
19   std::vector<i_gcobject *> unhold_set;
20 
21   bool set_changed;
22   bool hold_set_sorted;
23   bool unhold_set_sorted;
24 
25   void combine_set();
26   virtual void touch();
27 
28   virtual void hold(i_gcobject *obj) {
29     hold_set.push_back(obj);
30     hold_set_sorted = false;
31     set_changed = true;
32   }
33 
34   virtual void unhold(i_gcobject *obj) {
35     unhold_set.push_back(obj);
36     unhold_set_sorted = false;
37     set_changed = true;
38   }
39 
40   struct f_mark {
41     void operator() (i_gcobject *obj) {
42       obj->mark();
43     }
44   };
45 
46 public:
47 
48   gcholder() :  set_changed(false),  hold_set_sorted(true) ,  unhold_set_sorted(true) {  }
49 
50 };
51 
52 void gcholder::combine_set(){
53   if (!hold_set_sorted) {
54     std::sort(hold_set.begin(),hold_set.end());
55     hold_set_sorted = true;
56   }
57   if (!unhold_set_sorted) {
58     std::sort(unhold_set.begin(),unhold_set.end());
59     unhold_set_sorted = true;
60   }
61   if (!unhold_set.empty()) {
62     std::vector<i_gcobject *>::iterator iter1 = hold_set.begin();
63     std::vector<i_gcobject *>::iterator iter2 = unhold_set.begin();
64     while (iter1 != hold_set.end() && iter2 != unhold_set.end()) {
65       if (*iter1 == *iter2) {
66         *iter1 = NULL;
67         ++iter1;
68         ++iter2;
69       } else {
70         assert(*iter1 < *iter2);
71         ++iter1;
72       }
73     }
74     i_gcobject * null = NULL;
75     hold_set.erase(std::remove(hold_set.begin(),hold_set.end(),null) , hold_set.end());
76     unhold_set.clear();
77   }
78 }
79 
80 void gcholder::touch(){
81   if (set_changed) {
82     combine_set();
83     set_changed = false;
84   }
85   std::for_each(hold_set.begin(), hold_set.end(), f_mark());
86 }
87 
88 i_gcholder * i_gcholder::create(){
89   return new gcholder;
90 }


gcholder ????o????????????????a??????????1?????o???????????????|????????|???????3 i_gcobject ???????a???????????????????????o????????????????????????1??????|????1??????????????o????????o?????????|?????????????o?????????a???????????????a?????????????????? gc ?3?????????????o?????a???o????????????????????a??????a????1?????? collect ??3?????????????????????????????|??? collect ????????????????3??????????'??????'??? gc ??1?????3??????????
?????????????????a???????????????? stl ????? mutliset ??????o??????a???????????????????????????2????????1????????????????????????o?o??????a????????????1?????o???????????3?3?????1??????????o gc ?|?????-????????????

 1 /*  filename: test.cpp
 2  *  Copyright (c) 2010 ,
 3  *      Cloud Wu . All rights reserved.
 4  *
 5  *      http://www.codingnow.com
 6  *
 7  *  Use, modification and distribution are subject to the "New BSD License"
 8  *  as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.
 9  */
10 #include "gcobject.h"
11 #include <cstdio>
12 #include <set>
13 #include <algorithm>
14 
15 interface i_tree : virtual i_gcobject {
16   virtual void link(i_tree *p) = 0;
17   static i_tree * create();
18 };
19 
20 class tree : public virtual i_tree , virtual gcobject {
21   tree *parent;
22   std::multiset<tree *> children;
23   struct f_mark {
24     void operator() (tree *node) {
25       node->mark();
26     }
27   };
28 
29   virtual void touch() {
30     if (parent)
31       parent->mark();
32     std::for_each(children.begin(), children.end(), f_mark());
33   }
34 
35   void unlink();
36   virtual void link(i_tree *parent);
37 
38 public:
39   tree() : parent(NULL) {
40     printf("create node %p\n",this);
41   }
42 
43   ~tree() {
44     printf("release node %p\n",this);
45   }
46 
47 };
48 
49 
50 void tree::unlink() {
51   if (parent) {
52     parent->children.erase(this);
53     parent = NULL;
54   }
55 }
56 
57 void tree::link(i_tree *p){
58   unlink();
59   if (p) {
60     tree * cp = dynamic_cast<tree *>(p);
61     cp->children.insert(this);
62     parent = cp;
63   }
64 }
65 
66 i_tree *i_tree::create(){
67   return new tree;
68 }
69 
70 int main(){
71   i_tree *root = i_tree::create();
72   root->grab();
73   i_tree *node;
74   node = i_tree::create();
75   node->link(root);
76   node = i_tree::create();
77   node->link(root);
78   i_gcobject::collect();
79   printf("collected\n");
80   node->link(NULL);
81   i_gcobject::collect();
82   printf("finalize\n");
83   root->release();
84   i_gcobject::collect();
85   return 0;
86 }
??????????????????a??o?o? gc ?????1????????????????????1???o??|???????????????????????? i_gcobject ????????????|?????????-??? i_tree ???
?????????????????a????????????????????????? gcobject ???????|?????????-??? tree ???
?|?????????|????????? touch ??1?3?????? touch ??1?3???- mark ?????3??? gcobject ?????1?o? tree ????a????-???????????????o2????-??-?????1??? mark ???
??1?????????????????????????????????????o???1???? finalize ??????????????????-??????|????????????????????3??? gcobject ??????o??????? gc ?3???????????????????????|??? tree ?????????|??? ~tree ??- delete children ??1????-????????????1??????|?????a????????o2????1????????????
?|????????????a???????????o??????????????????|?????????? gcobject.h ????????o gcobject ??????????a???????? i_gcobject ???????????


Khan 2019-08-01 10:57 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2017/10/14/215297.htmlKhanKhanSat, 14 Oct 2017 08:26:00 GMThttp://www.598club.com/Khan/archive/2017/10/14/215297.htmlhttp://www.598club.com/Khan/comments/215297.htmlhttp://www.598club.com/Khan/archive/2017/10/14/215297.html#Feedback0http://www.598club.com/Khan/comments/commentRss/215297.htmlhttp://www.598club.com/Khan/services/trackbacks/215297.html?????????

Khan 2017-10-14 16:26 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2017/10/14/215296.htmlKhanKhanSat, 14 Oct 2017 04:26:00 GMThttp://www.598club.com/Khan/archive/2017/10/14/215296.htmlhttp://www.598club.com/Khan/comments/215296.htmlhttp://www.598club.com/Khan/archive/2017/10/14/215296.html#Feedback0http://www.598club.com/Khan/comments/commentRss/215296.htmlhttp://www.598club.com/Khan/services/trackbacks/215296.html

???????????

http://www.boost.org/doc/libs/1_60_0/doc/html/boost_asio/reference/coroutine.html

???????????

?????

????????????????|?????????????????????

class coroutine

???????????

???????? ????
coroutine ??????????o??????????????
is_child ?|????????????afork?-????????????????true
is_complete ?|???????o?????-?????????????true
is_parent ?|???????fork?????????????????????true

coroutine ???????????????????????????????????????a???ao????????????-??????????????????
coroutine江苏快三开奖结果 ????????????????????????????????????????????aint?????o?'??????????????????????o???????

class session : coroutine
{
 // ?????????
};

??????????o?????a??????1???

class session
{
  //?????????
  coroutine coro_;
};

???????????????o?????alambda?????bind????????????????? ????????????????1???????????-???????????????????a??1?????????????????????

??a??3???-?

???????????????1?????a??3???-???????????????o???a??3???-????????????????????o??????????1???
#include <boost/asio/yield.hpp>

???????????????????'????????1??????undefine

#include <boost/asio/unyield.hpp>

reenter

reenter???????????????1?????????????????????????????????1??a????? ??? ?????acoroutine?????????????????????????|? ??? ?|??????o?????coroutine???????????????? ???

reenter (this)
{
  //coroutine body 
}

?|????coroutine???????????????????

reenter (coro_)
{
  // coroutine body 
}

?????????reenter??????????????????????????'???3??????????????????yeild?????fork????????????????
???????????????1???????????????a??????????-???

reenter (this) for (;;)
{
  //?????????
}

??????: ???o?reenter????????swtich??????????????????????????????????????-????1?????????????????????????????3?????? ????a??????????????1??????????????????????3?????????1???

yield ?-???

????????????? yield ??3???-????????????????????-??????? :

yield socket_->async_read_some(buffer(*buffer_), *this);

江苏快三开奖结果????a??????4?-?a?????:

  • yield ????-?????????????????????.
  • ????????????-??????????
  • ????-??????1?????????o???????????
  • ?????3?????????????????????o?????.???

???????-?????????????????????????????????a???????????????????????-??????1??????????????????-????????????????????????????????????|???????

1 yield
2 {
3   mutable_buffers_1 b = buffer(*buffer_);
4   socket_->async_read_some(b, *this);
5 }

yield return expression ;

???????????????????????????o?o??????????????????????|? ???

 1 struct interleave : coroutine
 2 {
 3   istream& is1;
 4   istream& is2;
 5   char operator()(char c)
 6   {
 7     reenter (thisfor (;;)
 8     {
 9       yield return is1.get();
10       yield return is2.get();
11     }
12   }
13 };

????1??o??????a???????????'????????????a?????-?????????????

????a??????3?-?a?????

  • yield ????-?????????????????????.
  • ????-??????1?????????o???????????
  • ??????????????????????

yield ;

This form of yield is equivalent to the following steps:

江苏快三开奖结果????a??????3?-?a?????

  • yield ????-?????????????????????.
  • ????-??????1?????????o?'????????????
  • ????????????????????????????
    ???????????????????????????????o?????????????????o|????????????????|? ???
 1 struct task : coroutine
 2 {
 3   //?????????
 4   void operator()()
 5   {
 6     reenter (this)
 7     {
 8       while ( not finished )
 9       {
10          do something 
11         yield;
12          do some more 
13         yield;
14       }
15     }
16   }
17   //?????????
18 };
19 //?????????
20 task t1, t2;
21 for (;;)
22 {
23   t1();
24   t2();
25 }

yield break ;

?????????????????????????????o???????-??????????????????-?a???

  • yeild????????????????????o????-????
  • ????????????????????????????

?????|?????????-??????? is_complete()?????true ??? ???????????????????????
?3??? ??? ???????????????????????o????-?????????????????|?return ??? ?????o????????????????????????????????????????????????o????-????

fork statement

fork江苏快三开奖结果??a??3???-????????????????????a???????????????????????????a???????????????a??????????'??????????????????a???????o????????????????????o????????a???????????????????????a???????????????????

 1 reenter (this)
 2 {
 3   do
 4   {
 5     socket_.reset(new tcp::socket(io_service_));
 6     yield acceptor->async_accept(*socket_, *this);
 7     fork server(*this)();
 8   } while (is_parent());
 9   // client-specific handling follows 
10 }

江苏快三开奖结果????a???4??a?-?a????? ???

  • fork ????-?????????????????????.
  • ?????o?????a????????????????|??1?????????????????|??1??????????
  • ???????1?'??????????1????.
  • ??1?o????????????????1?????????????

?????is_parenet()???is_child()???????????????o???????????????a??????????????????????????????1?????????????????o?o????
?3?????? fork ??3???-??1??????????????????????????????o?????????o?????a????????????1?????????????????????????????????????????????1?????????????????io_server::post() ????????????????????????????

????????????

  • BOOST_ASIO_CORO_REENTER instead of reenter
  • BOOST_ASIO_CORO_YIELD instead ofyield
  • BOOST_ASIO_CORO_FORK instead of fork

?o????????

????o? ???

boost/asio/coroutine.hpp

 1 // ????1? coroutine ????? ???'???????????a?????????????
 2 // ???????????a???????2?????????????????????
 3 class coroutine
 4 {
 5 public:
 6   // ????????0
 7   /// Constructs a coroutine in its initial state.
 8   coroutine() : value_(0) {}
 9 
10   // fork ????-???????????????????????????????'??????????-????-????????|??o'??????
11   // ????-???????????????fork??????value_????????????????????????????????o???child??? 
12   /// Returns true if the coroutine is the child of a fork.
13   bool is_child() const { return value_ < 0; }
14   // ????? ??? is_child()
15   /// Returns true if the coroutine is the parent of a fork.
16   bool is_parent() const { return !is_child(); }
17 
18   // ???reenter????????????????????????o??????yeild?????fork ??? ??|???????a??????????????????????????????????????????-????????????????????????????????????????vaule_?????????o-1???
19   /// Returns true if the coroutine has reached its terminal state.
20   bool is_complete() const { return value_ == -1; }
21 
22 private:
23   friend class detail::coroutine_ref;
24   int value_;
25 };
26 
27 
28 namespace detail {
29 // ???????????????????a???????1???????????1& ??????coroutine ???????????
30 class coroutine_ref
31 {
32 public:
33   coroutine_ref(coroutine& c) : value_(c.value_), modified_(false) {}
34   coroutine_ref(coroutine* c) : value_(c->value_), modified_(false) {}
35   ~coroutine_ref() { if (!modified_) value_ = -1; }
36   operator int() const { return value_; }
37   int& operator=(int v) { modified_ = truereturn value_ = v; }
38 private:
39   void operator=(const coroutine_ref&);
40   int& value_;
41   bool modified_;
42 };
43 
44 // namespace detail
45 // namespace asio
46 // namespace boost
47 
48 #define BOOST_ASIO_CORO_REENTER(c) \
49   switch (::boost::asio::detail::coroutine_ref _coro_value = c)\
50     case -1if (_coro_value) \
51     { \
52       goto terminate_coroutine; \
53       terminate_coroutine: /*?????????reenter??????????????????????????*/\
54       _coro_value = -1; \
55       goto bail_out_of_coroutine; /*????o?????????*/\
56       bail_out_of_coroutine: \
57       break; \
58     } \
59     else case 0/*??????????????????????????*/
60 
61 #define BOOST_ASIO_CORO_YIELD_IMPL(n) \
62   for (_coro_value = (n);;) \
63     if (_coro_value == 0) \
64     { \
65       case (n): /*???reenter??????????????????????????1?????????'???3???????????????'???????????????*/; \
66       break; \
67     } \
68     else /*???????????????????*/\
69       switch (_coro_value ? 0 : 1) \
70         for (;;)  \
71           case -1if (_coro_value)/*????yeild break ????-? */ \
72             goto terminate_coroutine; \
73           else for (;;)/*????yeild ???????? yeild return ?????,??a??? */\
74             case 1if (_coro_value) \
75               goto bail_out_of_coroutine; \
76             else case 0:
77 
78 #define BOOST_ASIO_CORO_FORK_IMPL(n) \
79   for (_coro_value = -(n);; _coro_value = (n))/*????a??a???????????????????????? ??? core_calue == -n ?????-????????? core_value == n ????????????*/ \
80     if (_coro_value == (n)) \
81     { \
82       case -(n): ; \
83       break; \
84     } \
85     else
86 
87 #if defined(_MSC_VER)
88 # define BOOST_ASIO_CORO_YIELD BOOST_ASIO_CORO_YIELD_IMPL(__COUNTER__ + 1)
89 # define BOOST_ASIO_CORO_FORK BOOST_ASIO_CORO_FORK_IMPL(__COUNTER__ + 1)
90 #else // defined(_MSC_VER)
91 # define BOOST_ASIO_CORO_YIELD BOOST_ASIO_CORO_YIELD_IMPL(__LINE__)
92 # define BOOST_ASIO_CORO_FORK BOOST_ASIO_CORO_FORK_IMPL(__LINE__)
93 #endif // defined(_MSC_VER)
94 
95 #endif // BOOST_ASIO_COROUTINE_HPP
96 




Khan 2017-10-14 12:26 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2017/10/14/215295.htmlKhanKhanSat, 14 Oct 2017 03:44:00 GMThttp://www.598club.com/Khan/archive/2017/10/14/215295.htmlhttp://www.598club.com/Khan/comments/215295.htmlhttp://www.598club.com/Khan/archive/2017/10/14/215295.html#Feedback0http://www.598club.com/Khan/comments/commentRss/215295.htmlhttp://www.598club.com/Khan/services/trackbacks/215295.html?????????

Khan 2017-10-14 11:44 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2015/07/09/211203.htmlKhan???]??? ????????I/O?????3?????????????a??????????????????o????????????????????????? ???????????????????o???? ?????????'?o????????o??????????????o??????? ??'???????????????-????IO?????????????'????????????????o????-???????3?????o?????????????o?????????????????????????a??a'1???o??o???????read()??????????'????? ????-??????????????????????'??????-????'?3???????????socket????-???-????????????????

江苏快三开奖结果???????1??????????????????-????????????3?????????????????????????????????????|??-??-??????????????????????????????????????|??1??-?????????????????o?;|??1??3?????????????????????????????????????o???????????????????-??-????????????o|????????????|?read()????????? ?|??????????socket????????????????????????3?????EWOULBLOCK/EAGAIN???????????read()??”????????2?????????????????????????”???

?????????????-??????-????????????????????????????????3???????????????????????????????????2?????????o?????3??????????????|????????o???????o??????????????????????????????1????????????????????????????????????|???????????????????????Windows???ReadFile()?????POSIX???aio_read()????'??????????1?????????????????3???????????????3?????????????????????????????????

江苏快三开奖结果?????????????IO????????-??????????????-????????????????????????????????????

????????????????????????I/O???????o????1????????????跨?13??????????????(???3??1???)??? ???????-?????????????o?TCP??????????????????????????o????????????????????3?????????1????????????????????????? Java???C#??? C++????a??1??????1???????????????????????? ????????????????????????????????????????????????1????o?????????o????????I/O??????????o?????????????????????1?????????????????????????|??????

????IO?????????1???:Reactor and Proactor

江苏快三开奖结果?????????????????I/O ??????o?????|??o????????o???(event demultiplexor [???])??? ?o????????o????????????????3?????o???????o?????o???????????????????o??????????????????????????????????????????: ????????1?????????o???? ?????????????????????oo?????????????????????|???????o????????3????????'??????o????????1???????????o???????????(event handlers)????????????????????; ?o????????o???????????????????????????????o????????????????o?handler?????????????????

?????????o????????o??????????????????o???Reactor and Proactor []??? Reactor??????????o?o?????-?I/O????????Proactor???????????????-?I/O?????3?????? ??Reactor???????-????o????????|????-?????????a?o?????????????o????????a????????????????????????????|?????????????|???????????????????socket???????????????o????????|???????????a?o???????????o?????3???????o??????????????????????????????????????????????????????????????????

江苏快三开奖结果????Proactor???????-????o???????????(???????????o????????|???????)??'????????????a????-????????????(???????o????)??????????????????????????????3???????????????????????????????|????????????????????????o??-????????????????????-???o???????????????????????????o??-?????????????????????-???o?????????????a??????????????????????-???????????o????????|??????????o?????a??????????????-????????a?????????????????????????????????o???????????o?????o?????????????????????????????????'?????Windows????o?????????????????o??????a????-?IO??????(????overlapped?????????)????o????????|????-?IOCompletion?o??????????[]??? ????????-?????????????????????????o?o????????3?????o???????-?API???????????????????????1???o“?3?????o???”????????“????-?????1????”???????-?????????o?????????????????????????3?????????3??????

江苏快三开奖结果?????|????a????-??????'?????????Reactor???Proactor??????????????o??????????????????a??3?3read??????????????owrite???????1?????????????????????????Reactor???????3????

  • ?????a?o????????????????????1?????asocket?????????o????????????'??;
  • ?o????????|????-????????a?o?????????????;
  • ????o???????????o?????o????????|??????????????'?'????????????????a?o???????????;
  • ?o??????????????????????????o???????????asocket???????????o???? ?|??????|???????????????????1????asocket?????????o?????????'??????????'?????????????-?a;

江苏快三开奖结果?????????????????????-?????1????????-??????Proactor????|?????????????

  • ?o?????????????'????????????????a?????????(????????????????3???????????????????a????-???????)??? ????a??????????o?????????????1????????3??????o????????????a?????????1???a?????????-??????|?|??????????a???????????????????o???????????a?????????????????????a?????????????????????o?????o??????a?-????????oo????3???????????????????????????????????????a?????
  • ?o????????|????-????????a???o?????????????(???????????Reactor?????????);
  • ????o????????|????????-???????????o????????????????????????????3?????2?????????1??????12?'??o????????????????????????????????????????????????????-???o??-???????????????o????????|??????????a?o??????????????o?;
  • ?o????????o?????????1????????o???????????: ?????????????o???????????o?;
  • ?o??????????????????????????3|????????????2????1??1????????????????????????-???o??-?????3????1???????????o?????|?????????|?????o?????????????????1???????????????|???????a????????????????????????????a?-?a????????

????????3?

江苏快三开奖结果????o?C++???????????? ACE[???](Douglas Schmidt, et al.??????) ???????o?????13????????????o????1????????????(?o???????o???????-?)??? ??????????'???????????1????????o????????????????C++????????o??????Reactor???Proactor???????? ?????????????????13??????????????????????????????????????o???????????????????

江苏快三开奖结果ACE Proactor??MS-Windows???????o???????????????????????'??????-1????????|???????o?Windows???????o?????3?????????????o???????-?API??? [???]???

江苏快三开奖结果(????????????????o???1??) ????1???????????1????????????????????3????????o?o???????-???????????????????????????????????'??? ????Unix?3????????o???|???????-??? ACE Reactor????????Unix?3?????????'???????????3??1?????? ?-??????o?3?????o????????????????o|???????????o?o???????3????????????'????????????????????????????????'??????????????????????????: ??oWindows????????ACE Proactor????????oUnix?3?????????????ACE Reactor???

???????????????????????????-????????-????????|????????3?????o??????????????????o??o?????????????????????3?????o?o??????????????oReactor???Proactor????????????????????????????????????????????????????1???????????????????????????????1????????

江苏快三开奖结果??'?????????3??1???

???????????????????????????????????????????????????o?Proactor???Reactor???????????????3??1?????? ??o?o?????o????a??1??????????????Reactor????????'???????????????-????Proactor?????(???|???????o????????|?????????????????o????????????????????????????????????????????????1?3???o”?????????-?“)??? ?????????o???????????????read??????????|?????????????:

  • ?o?????????????????1???o?????????'??????1????????o????o??-????????????????-???o?????????????o|?-??????;
  • ??????-????(????|?????select());
  • ???????o?????????(??3?????)????????????????? ??????????????????????????????(??????o????????????2???????o??3????????????o?)??????????????????????????o??????????????
  • ?o?????????????????????????????????2???????????????????????'???????????3|??????????????o????

江苏快三开奖结果????????????????????o????|???(?1???????????????)?????????o?????????????????Reactor????????????oProactor?????????????????o???????????????????????????????Reactor??????o???????????????'??????????????a????????????????????????????????????2????????????2????????1??????????????????????????1?????????????????????????????????????????????????????????????????????a????????????????????????????o??????????o???????

?????????????????? Reactor?????:

  • ?-?a 1) ?-?????o???? (Reactor ????????)
  • ?-?a 2) ???”?2????????”?o???????????o?????3???????o???????????????????? ( Reactor |???????)
  • ?-?a 3) ??????? (??????????|???????)
  • ?-?a 4) ?????????? (??????????|???????)

????????Proactor?????:

  • ?-?a 1) ?-?????o???? (Proactor ????????)
  • ?-?a 2) ???????(????????????????????o??? Proactor ???????a?o????)
  • ?-?a 3) ?????????2??????????????????????????????????????????3?o???????????(Proactor |???????)
  • ?-?a 4) ?????????? (??????????|???????)

江苏快三开奖结果???2?????o???????-?I/O API????????????????3?????????????1?3???????????????????????socket??????????????(????o??????????????????)??? ???????????a???????????????????“????-???????”??????????????????????????????-??13??????????????????????o????

TProactor

???????????o???TProactor??1????2?????TerabitP/L []????????????o???? ???????????????: C++??????Java??????C++????????????o?ACE?13????????????o?????????????????????????????????3??????????????o??????????????-??????????

TProactor??-?????|??????????|???Engine???WaitStrategy?o???? Engine???o???'??????-??????????????????????????WaitStrategy???o????????1?????-??????? WaitStrategy???Engine?????????????1??o???????? ?????'???????o???????????1???????????

江苏快三开奖结果Engines????-?????-????????????????o|????????????(?????'???????????????????????1)???TProactor??????o|?????????????1???????????????????-???????API???????-?Unix API(select(), poll(), /dev/poll (Solaris 5.8+), port_get(Solaris 5.10),RealTime (RT) signals (Linux 2.4+), epoll (Linux 2.6), k-queue (FreeBSD) )????????????????o????????????(POSIX AIO, SUN AIO and Emulated AIO)?1??????o???-???-?????-???????TProactor??????o????????????? ACE Proactor????????????????????????????????o???????13???????????????????????a??????????????????跨?13?????3??1????????o????????

Engines???WaitStrategies??????????1?????????????a????????????????????????????????????????????????????????????????????????o????????????????-?????-??????????????????1????????????????????????|????????????3???????????????????????????????????3?????-?????|?????3??????????????o????????-??o???API??????????oo??????????????????-????????-??-?????????|????????1????????????????????????o??????????-????????????????????????-??????????????????????????a??|???3?3?????????????????????????a????????????-?????????

江苏快三开奖结果??????????'?????1?o???????Sun Solaris??????HTTP????????????|??????|???????????????????????/dev/poll?????port_get()?1?????????????????????????????????????|??????|???????????????????????o???select()??????????????'?????????o?????????????-?????????????3???????????????????????1????????????????ACE Reactor/Proactor????????????3???????????????????2??????

江苏快三开奖结果????????1???????????????????????o????????????-???????1???a????????????????????2???????????????????????????????????????????1??????????????????????????TProactor?????????-????ACE Reactor??Unix/Linux?3????????????o|10-35%?????????????????Windows??????????(??????o????????????????o?????')???

????????? (JAVA / C++ / C#).

江苏快三开奖结果??o?C++??????????1???Java??-??????o?TProactor??? JDK1.4??-??? Java??????????o?????-???1?3???? ???C??-???select() [???]??? Java TProactor??o?o?Java???????????????(java.nio???),??????o?C++???TProactor??????o?select()?????????

???1???2????o?o???? bits/sec??o?????????????????o|??????????o?????????????????o??????????o??????????????1???????????echo?????????????????ACE Reactor?????(??o?o?RedHat Linux9.0)???TProactor C++/Java?????(Microsoft Windows?13?????RedHat v9.0)??? ??????C#????????????????????????????????????????????????????????????????????????????????'??-?????????o????????????????????

?????????????????????????????????????????????????????????????????????????1????????1????1????????????



??? 1. Windows XP/P4 2.6GHz HyperThreading/512 MB RAM.




??? 2. Linux RedHat 2.4.20-smp/P4 2.6GHz HyperThreading/512 MB RAM.


江苏快三开奖结果???????????o???

????????TProactor Java????????echo?????????????????????????????????'?????????????a??|??????????a???????????????OpRead??????????-???????????????????-?????o????OpWrite??????????-?????????????????????-???o??????????????????????|?????????onReadComplated()???onWriteCompleted()???????????????3?????????????????????o????????????????????????????????


 1 class EchoServerProtocol implements AsynchHandler
 2 {
 3  
 4   AsynchChannel achannel = null;
 5  
 6   EchoServerProtocol( Demultiplexor m,  SelectableChannel channel ) 
 7   throws Exception
 8   {
 9     this.achannel = new AsynchChannel( m, this, channel );
10   }
11  
12   public void start() throws Exception
13   {
14     
15 // called after construction
16     System.out.println( Thread.currentThread().getName() + 
17     ": EchoServer protocol started" );
18     achannel.read( buffer);
19   }
20  
21   public void onReadCompleted( OpRead opRead ) throws Exception
22   {
23     if ( opRead.getError() != null )
24     {
25       
26 // handle error, do clean-up if needed
27       System.out.println( "EchoServer::readCompleted: " + 
28       opRead.getError().toString());
29       achannel.close();
30       return;
31     }
32  
33     if ( opRead.getBytesCompleted () <= 0)
34     {
35       System.out.println("EchoServer::readCompleted: Peer closed "
36        + opRead.getBytesCompleted();
37       achannel.close();
38       return;
39     }
40  
41     ByteBuffer buffer = opRead.getBuffer();
42  
43     achannel.write(buffer);
44   }
45  
46   public void onWriteCompleted(OpWrite opWrite) 
47   throws Exception
48   {
49     
50 // logically similar to onReadCompleted
51     
52   }
53 }


江苏快三开奖结果IO???????????????????Proactor???Reactor????????????o??????|????o?IO???????-??????????-????

Proactor???Reactor??'????????

???????????????????????????????????

?????????

Proactor

  1. client?????o|??????????????????1??3???????????????????????????????????
  2. ?????????opration????o?????????3?????o????????????
  3. ???????????????o???????????????????????????????????Proactor??o|??
  4. Proactor??o|?????????????o???????????????????????????????????

Reactor

  1. ??1?o?????????3????????????????
  2. client??????|????o???????o???????
  3. Reactor??o|?????????o??????????????????3???????????????????

??o?????????3?

??o???

?????????-???Proactor????????o????-?IO???????o?????????3??????????IO?????????????????a????

江苏快三开奖结果??Reactor???????????????3??????????????o?????????????????a??????1???????3????????-?IO???????????????????????3???????????????????

????-?o????????o??????o?IO??????OS???????????????o????????????????3????-????????-?IO???

????-?IO??windows????????????????????????????????????????????Linux?-?Unix?3???????????3???????????????????????????????????????????Reactor???????o??????

???3?

?????????????IO??????????????o?IO????????????o?o??o?????????1??????????????????????????“?o??????”????1?????????????-??????????????????????????o???OS???????????????????????????????????





???????-


TProactor??o????a?13?????????o??????a?????????1????????????????????????????????????????????o????????2??-?????????????????????????????????????????-?o????

????????????????-?????????????????oC++?????????????????????????????????3?????????????Java?2?'?????????????????????oJava???o????????????????????????Windows???????????3(???2????o????????o?????2?o???)???

江苏快三开奖结果??|??3??????????????????????1Java????????????????????????????????????????????????a?????????????????????(?????????)???

?o??AIO??Linux????????????????[]??? ????????????????Linux??????API????????????????'?????o??????????-?API??? ?|??-??????????????o?o??-???????????????Engine/?-?????-??????????????????3????????1?????????????1???????1???????????ACE Proactor???????????????

????? I

TProactor??-????????Engines ??? ?-?????-????

????????????-?????-???????????3????
POSIX_AIO (true async)
aio_read()/aio_write()
aio_suspend()
Waiting for RT signal
Callback function
POSIX complained UNIX (not robust)
POSIX (not robust)
SGI IRIX, LINUX (not robust)
SUN_AIO (true async)
aio_read()/aio_write()
aio_wait() SUN (not robust)
Emulated Async
Non-blockingread()/write()
select()
poll()
/dev/poll
Linux RT signals
Kqueue
generic POSIX
Mostly all POSIX implementations
SUN
Linux
FreeBSD

????? II

江苏快三开奖结果??????????-??-?????-???????????????o?????:

  • edge-triggered (e.g. Linux???????????) – signal readiness only when socket became ready (changes state);
  • level-triggered (e.g. select()poll(), /dev/poll) – readiness at any time.

????????????????????????????o?????????????????:

  • edge-triggered group: after executing I/O operation, the demultiplexing loop can lose the state of socket readiness. Example: the “read” handler did not read whole chunk of data, so the socket remains still ready for read. But the demultiplexor loop will not receive next notification.
  • level-triggered group: when demultiplexor loop detects readiness, it starts the write/read user defined handler. But before the start, it should remove socket descriptior from theset of monitored descriptors. Otherwise, the same event can be dispatched twice.
  • Obviously, solving these problems adds extra complexities to development. All these problems were resolved internally within TProactor and the developer should not worry about those details, while in the synch approach one needs to apply extra effort to resolve them.

[6] TProactor (ACE compatible Proactor).
www.terabit.com.au

[7] JavaDoc java.nio.channels

[8] JavaDoc Java.nio.channels.spi Class SelectorProvider

[9] Linux AIO development
, and

??'??

江苏快三开奖结果Ian Barile “I/O Multiplexing & Scalable Socket Servers”, 2004 February, DDJ

Further reading on event handling

The Adaptive Communication Environment

Terabit Solutions

??3?o??????

Alex Libman has been programming for 15 years. During the past 5 years his main area of interest is pattern-oriented multiplatform networked programming using C++ and Java. He is big fan and contributor of ACE.

Vlad Gilbourd works as a computer consultant, but wishes to spend more time listening jazz :) As a hobby,he started and runs  website.


???????????





Khan 2015-07-09 11:00 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2015/06/02/210799.htmlKhanKhanTue, 02 Jun 2015 02:17:00 GMThttp://www.598club.com/Khan/archive/2015/06/02/210799.htmlhttp://www.598club.com/Khan/comments/210799.htmlhttp://www.598club.com/Khan/archive/2015/06/02/210799.html#Feedback1http://www.598club.com/Khan/comments/commentRss/210799.htmlhttp://www.598club.com/Khan/services/trackbacks/210799.html
???. ????? brew, ?|?????2???, ???????? 
ruby -e "$(curl -fsSL http://raw.github.com/Homebrew/homebrew/go/install)"

?o?. ?????? xcode ??????, ????? xcode command tools ??????
brew doctor
xcode-select --install

???. ?????  ????? ????? ?????python cmake qt
brew install python cmake qt

???. ????? pip wheel ??????
pip install wheel

?o?. ????? wget ????
brew install wget

??-. ?-???. ????????????????????????????. ???????o??-????????? pyside ??????????o?. 
1. ?????????????????????. 
    export MACOSX_DEPLOYMENT_TARGET=10.10

2.????????? pyside
    wget http://pypi.python.org/packages/source/P/PySide/PySide-1.2.2.tar.gz
    tar -xvzf PySide-1.2.2.tar.gz
    cd PySide-1.2.2

3.?????
    python setup.py bdist_wheel

4. ?????????o??? whl ???. 
    sudo pip install dist/PySide-1.2.2-cp27-none-macosx_10_10_x86_64.whl

5. ????? pyside ??????
    sudo python pyside_postinstall.py  -install

Khan 2015-06-02 10:17 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2015/01/04/209386.htmlKhanKhanSun, 04 Jan 2015 05:10:00 GMThttp://www.598club.com/Khan/archive/2015/01/04/209386.htmlhttp://www.598club.com/Khan/comments/209386.htmlhttp://www.598club.com/Khan/archive/2015/01/04/209386.html#Feedback2http://www.598club.com/Khan/comments/commentRss/209386.htmlhttp://www.598club.com/Khan/services/trackbacks/209386.html
 1 #!/usr/bin/python
 2 # Filename: ipaInfo3.py
 3 # author khan.lau
 4 
 5 # python 3.x
 6 
 7 import zipfile, plistlib, sys, re
 8 
 9 
10 def analyze_ipa_with_plistlib(ipa_path):
11     ipa_file = zipfile.ZipFile(ipa_path)
12     plist_path = find_plist_path(ipa_file)
13     plist_data = ipa_file.read(plist_path)
14     plist_root = plistlib.loads(plist_data)
15     print_ipa_info(plist_root)
16 
17 def print_ipa_info(plist_root):
18     print ('Display Name: %s' % plist_root['CFBundleName'])
19     print ('Bundle Identifier: %s' % plist_root['CFBundleIdentifier'])
20     print ('Version: %s' % plist_root['CFBundleShortVersionString'])
21 
22 def find_plist_path(zip_file):
23     name_list = zip_file.namelist()
24     # print name_list
25     pattern = re.compile(r'Payload/[^/]*.app/Info.plist')
26     for path in name_list:
27         m = pattern.match(path)
28         if m is not None:
29             return m.group()
30 
31 
32 
33 if __name__ == '__main__':
34     args = sys.argv[1:]
35     if len(args) < 1:
36         print ('Usage: python ipaInfo3.py /path/to/ipa')
37         exit(0);
38  
39     ipa_path = args[0]
40     analyze_ipa_with_plistlib(ipa_path)
41 


python 2.7.x
 1 #!/usr/bin/python
 2 # Filename: ipaInfo2.py
 3 # author khan.lau
 4 
 5 # python 2.7.5
 6 # project need third_party lib biplist, please run 'sudo pip install biplist'
 7 
 8 import zipfile, biplist, sys, re
 9 
10 
11 def analyze_ipa_with_plistlib(ipa_path):
12     ipa_file = zipfile.ZipFile(ipa_path)
13     plist_path = find_plist_path(ipa_file)
14     plist_data = ipa_file.read(plist_path)
15     plist_root = biplist.readPlistFromString(plist_data)
16     print_ipa_info(plist_root)
17 
18 def print_ipa_info(plist_root):
19     print ('Display Name: %s' % plist_root['CFBundleName'])
20     print ('Bundle Identifier: %s' % plist_root['CFBundleIdentifier'])
21     print ('Version: %s' % plist_root['CFBundleShortVersionString'])
22 
23 def find_plist_path(zip_file):
24     name_list = zip_file.namelist()
25     # print name_list
26     pattern = re.compile(r'Payload/[^/]*.app/Info.plist')
27     for path in name_list:
28         m = pattern.match(path)
29         if m is not None:
30             return m.group()
31 
32 
33 
34 if __name__ == '__main__':
35     args = sys.argv[1:]
36     if len(args) < 1:
37         print ('Usage: python ipaInfo2.py /path/to/ipa')
38         exit(0);
39  
40     ipa_path = args[0]
41     analyze_ipa_with_plistlib(ipa_path)


python2.7 ????????? plistlib, ????????|???????????????1?o? biplist,  ????? easy_install ??? pip ??????o???3???, biplist ?????? data ????, ?????1?o? plistlib ???2, ??a????1?????????????, ?????????????


Khan 2015-01-04 13:10 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2014/10/29/208709.htmlKhanKhanWed, 29 Oct 2014 11:27:00 GMThttp://www.598club.com/Khan/archive/2014/10/29/208709.htmlhttp://www.598club.com/Khan/comments/208709.htmlhttp://www.598club.com/Khan/archive/2014/10/29/208709.html#Feedback0http://www.598club.com/Khan/comments/commentRss/208709.htmlhttp://www.598club.com/Khan/services/trackbacks/208709.html//????????a??????????-|???
#pragma clang diagnostic push
#pragma clang diagnostic ignored
"-Wunused-function”
static int aaa(){}
#pragma clang diagnostic pop


//??????arc performSelector leaks 
#pragma clang diagnostic push
#pragma clang diagnostic ignored
"-Warc-performSelector-leaks"
        [ item.event_target performSelector: item.sector];
#pragma clang diagnostic pop 



??o????????? 

Khan 2014-10-29 19:27 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2014/07/31/207870.htmlKhanKhanThu, 31 Jul 2014 04:32:00 GMThttp://www.598club.com/Khan/archive/2014/07/31/207870.htmlhttp://www.598club.com/Khan/comments/207870.htmlhttp://www.598club.com/Khan/archive/2014/07/31/207870.html#Feedback0http://www.598club.com/Khan/comments/commentRss/207870.htmlhttp://www.598club.com/Khan/services/trackbacks/207870.html2. pip install python-tk    //????pip????? python-tk

Khan 2014-07-31 12:32 ???????o
]]>
C++博客-Khan's Notebook GCC/GNU/Linux Delphi/Window Java/Anywhere http://www.598club.com/Khan/archive/2014/06/21/207361.htmlKhanKhanSat, 21 Jun 2014 07:33:00 GMThttp://www.598club.com/Khan/archive/2014/06/21/207361.htmlhttp://www.598club.com/Khan/comments/207361.htmlhttp://www.598club.com/Khan/archive/2014/06/21/207361.html#Feedback0http://www.598club.com/Khan/comments/commentRss/207361.htmlhttp://www.598club.com/Khan/services/trackbacks/207361.html????????????????????a??1iOS 5?????|???????????????????1????????????o??a????1?????????????iOS 5??????????a????1???????????????????1??2???????????????????????-???????oo??????????o???|??????????oo?????????????'???????????????1?????a?????????????????????????????3????a????????-??????1?3????????????????????????????o????1?????????'1??????????o????????oo????????|???????????????o???1?3?????|?drawRect:???

???iOS 5?????????1???????????a????????UIAppearance???UIAppearanceContainer???????o???1????UIKit?????????????????????????????????aUIAppearance????????UI??????????????????????????????????????????????|??-???UIAppearance?????????3???????????????o?o????????????????o?????????????????????????1??????'???????????a???????????????1?????????-???????????????????????????????|?UIBarButtonItem???tintColor江苏快三开奖结果???????1??????????????????????????????????1??????????????????????????????????????????????????a????-????

|????????o?????-???????????????????????2???????????UIBarButtonItem??????????????-?????tintColor???

[[UIBarButtonItem  appearance]  setTintColor:[UIColor  redColor]];

?3??????iOS 4?????????setTintColor??1?3????UIBarButtonItem江苏快三开奖结果??-?o????????????a???????????????a??1??????????????????????????????????????-???????????????????????????1??????????????????????????????????????o???????????1??????????

????????????????1?????????????????????????|??????1?3????????????????????????

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil]  setTintColor:[UIColor redColor]];

????????a???????????nil????????????????1????????????????????UINavigatorBar???UIPopOverController?-?????aUIAppearanceContainer江苏快三开奖结果?????????????

???iOS 5?????????????UI????'??????????o???1UIAppearance??????????????????-?????iOS 5??-??????o?UISwitch?????????????????????1???????on?????3??????2????????????????????????2??????????????1?????????a?o??????????????????UIKit???????????????????????????????'??????????????'???-?????a?o???????????????????????1????????????3????????????????????|?????a????3????????????????oo??????????????????1?????????'?????????????????1?o????UIKit????'?????'??????????????-????????|???UI_APPEARANCE_SELECTOR?????????????????????????????????????????????????a????-????UINavigationBar.h??-???tintColor??????|???UI_APPEARANCE_SELECTOR???????

@property(nonatomic,retain) UIColor *tintColor    UI_APPEARANCE_SELECTOR;

江苏快三开奖结果?????3????????????

[[UINavigationBar   appearance]  setTintColor:newColor];

??????????????1????????1?????Mac???iOS?13?????????????UI???????????????????????????????o???????????1????a???????????o??????????|??????Reminder?o???????1?????o???o|?????????????????????????????????????????o?UIAppearance江苏快三开奖结果??????????????????????????????????????|???????????



Khan 2014-06-21 15:33 ???????o
]]>