Changeset 34192 for lang/objective-cplusplus
- Timestamp:
- 06/30/09 12:28:54 (4 years ago)
- Location:
- lang/objective-cplusplus/i3/trunk
- Files:
-
- 3 modified
-
am/mil_test.am (modified) (1 diff)
-
src/mil/include/mil/ModuleCommon.h (modified) (1 diff)
-
src/mil/include/mil/gui-cocoa/GuiModule.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/objective-cplusplus/i3/trunk/am/mil_test.am
r34164 r34192 7 7 src/mil/src/TestMain.cpp \ 8 8 src/mil/src/StaticData.cpp \ 9 src/mil/src/Test7.cpp \ 10 src/mil/src/Test1.cpp \ 11 src/mil/src/Test2.cpp \ 12 src/mil/src/Test3.cpp \ 13 src/mil/src/Test4.cpp \ 14 src/mil/src/Test5.cpp \ 15 src/mil/src/Test6.cpp 9 src/mil/src/Test8.cpp 10 #src/mil/src/Test7.cpp \ 11 #src/mil/src/Test1.cpp \ 12 #src/mil/src/Test2.cpp \ 13 #src/mil/src/Test3.cpp \ 14 #src/mil/src/Test4.cpp \ 15 #src/mil/src/Test5.cpp \ 16 #src/mil/src/Test6.cpp 16 17 #src/mil/src/BoostTestDummyLib.cpp 18 17 19 18 20 -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/ModuleCommon.h
r34164 r34192 271 271 #ifdef MIL_GUI_WINDOWS 272 272 HWND hWnd; 273 #elif MIL_GUI_COCOA 274 NSWindow* window; 273 275 #endif 274 276 } thread[MIL_MAX_THREADS]; -
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModule.h
r34164 r34192 15 15 Tls tls; 16 16 private: 17 class EventBase : public boost::noncopyable18 {19 public:20 void (*execute)(void* event, void* target);21 intptr_t owner_id;22 EventBase* next;23 };24 25 class EventList : public boost::noncopyable26 {27 EventBase* head;28 EventBase* tail;29 boost::details::pool::default_mutex m;30 typedef boost::details::pool::guard<boost::details::pool::default_mutex> guard;31 public:32 EventList()33 {34 head = NULL;35 tail = NULL;36 }37 38 void push(EventBase& e)39 {40 guard g(m);41 e.next = NULL;42 if (head == NULL) // tail == NULL43 {44 head = &e;45 tail = &e;46 return;47 }48 tail->next = &e;49 tail = &e;50 }51 52 void pop()53 {54 guard g(m);55 if (!head)56 {57 return;58 }59 head = head->next;60 }61 62 EventBase* top()63 {64 guard g(m);65 return head;66 }67 68 void clear()69 {70 guard g(m);71 head = NULL;72 tail = NULL;73 }74 };75 76 77 17 template <typename T> 78 class Event : public EventBase18 class Event : boost::noncopyable 79 19 { 80 20 public: … … 86 26 87 27 private: 88 EventList list;89 Conditional c;90 28 bool repost; 91 atomic<bool> isWaiting; 29 92 30 protected: 93 31 NSWindow *window; 94 32 95 33 public: 96 34 NSWindow getWindow() 35 { 36 return window; 37 } 38 97 39 void requestExit(void* event_memory) 98 40 { 99 list.clear();100 41 ExitEvent e; 101 post(e, exitNotifier, event_memory, exitNotifier.tls.thread_id);42 post(e, *this); 102 43 } 103 44 104 GuiModule() : tls(this->thread_id), repost(false), isWaiting(false),window(NULL)45 GuiModule() : tls(this->thread_id), repost(false), window(NULL) 105 46 { 106 47 set_auto_join(this); … … 136 77 if (target.repost) 137 78 { 138 target. list.push(event);79 target.post(event.data, target); 139 80 return; 140 81 } 141 142 freeEvent<Sender>(event, target);143 82 } 144 83 public: … … 152 91 void post(const T& event, Sender& sender, void* memory = NULL, intptr_t owner_id = 0) 153 92 { 154 void* p = NULL; 155 if (memory) 156 { 157 p = memory; 158 } 159 else 160 { 161 pool::Producer& producer = sender.tls.producer; 162 p = producer.malloc<sizeof(Event<T>)>(); 93 NSWindow* localWindow = sender.tls.thread[this->thread_id].window; 94 if (!localWindow) { 95 localWindow = getWindow(); 96 sender.tls.thread[this->thread_id].window = localWindow; 163 97 } 164 98 165 if (p == NULL) 166 { 167 // XXX 168 return; 169 } 170 171 Event<T>* e = new(p) Event<T>; 172 e->data = event; 173 e->execute = dispatcher<T, Sender>; 174 if (memory) 175 { 176 e->owner_id = owner_id; 177 } 178 else 179 { 180 e->owner_id = sender.tls.thread_id; 181 } 182 183 list.push(*e); 184 if (isWaiting.load()) 185 { 186 c.signal(); 187 } 99 Event<T> e; 100 e.data = event; 101 e.execute = dispatcher<T, Sender>; 188 102 } 189 103 public: … … 205 119 void execute_front() 206 120 { 207 EventBase* e = list.top();208 if (!e)209 {210 return;211 }212 e->execute((void*)e, (void*)this);213 121 } 214 122
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)