Show
Ignore:
Timestamp:
06/30/09 12:28:54 (4 years ago)
Author:
saturday06
Message:

iaiodjfd

Location:
lang/objective-cplusplus/i3/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/objective-cplusplus/i3/trunk/am/mil_test.am

    r34164 r34192  
    77src/mil/src/TestMain.cpp \ 
    88src/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 
     9src/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 
    1617#src/mil/src/BoostTestDummyLib.cpp 
     18 
    1719 
    1820 
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/ModuleCommon.h

    r34164 r34192  
    271271#ifdef MIL_GUI_WINDOWS 
    272272        HWND hWnd; 
     273#elif MIL_GUI_COCOA 
     274        NSWindow* window; 
    273275#endif 
    274276    } thread[MIL_MAX_THREADS]; 
  • lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModule.h

    r34164 r34192  
    1515    Tls tls; 
    1616private: 
    17     class EventBase : public boost::noncopyable 
    18     { 
    19     public: 
    20         void (*execute)(void* event, void* target); 
    21         intptr_t owner_id; 
    22         EventBase* next; 
    23     }; 
    24  
    25     class EventList : public boost::noncopyable 
    26     { 
    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 == NULL 
    43             { 
    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  
    7717    template <typename T> 
    78     class Event : public EventBase 
     18    class Event : boost::noncopyable 
    7919    { 
    8020    public: 
     
    8626 
    8727private: 
    88     EventList list; 
    89     Conditional c; 
    9028    bool repost; 
    91     atomic<bool> isWaiting; 
     29 
    9230protected: 
    9331    NSWindow *window; 
    9432 
    9533public: 
    96  
     34    NSWindow getWindow() 
     35    { 
     36        return window; 
     37    } 
     38     
    9739    void requestExit(void* event_memory) 
    9840    { 
    99         list.clear(); 
    10041        ExitEvent e; 
    101         post(e, exitNotifier, event_memory, exitNotifier.tls.thread_id); 
     42        post(e, *this); 
    10243    } 
    10344 
    104     GuiModule() : tls(this->thread_id), repost(false), isWaiting(false), window(NULL) 
     45    GuiModule() : tls(this->thread_id), repost(false), window(NULL) 
    10546    { 
    10647        set_auto_join(this); 
     
    13677        if (target.repost) 
    13778        { 
    138             target.list.push(event); 
     79            target.post(event.data, target); 
    13980            return; 
    14081        } 
    141  
    142         freeEvent<Sender>(event, target); 
    14382    } 
    14483public: 
     
    15291    void post(const T& event, Sender& sender, void* memory = NULL, intptr_t owner_id = 0) 
    15392    { 
    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; 
    16397        } 
    16498 
    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>; 
    188102    } 
    189103public: 
     
    205119    void execute_front() 
    206120    { 
    207         EventBase* e = list.top(); 
    208         if (!e) 
    209         { 
    210             return; 
    211         } 
    212         e->execute((void*)e, (void*)this); 
    213121    } 
    214122