[aquaskk-changes 439] CVS update: AquaSKK

Back to archive index

t-suw****@users***** t-suw****@users*****
2007年 12月 21日 (金) 22:11:21 JST


Index: AquaSKK/AquaSKKServer.mm
diff -u AquaSKK/AquaSKKServer.mm:1.3 AquaSKK/AquaSKKServer.mm:1.4
--- AquaSKK/AquaSKKServer.mm:1.3	Mon Dec 18 00:05:41 2006
+++ AquaSKK/AquaSKKServer.mm	Fri Dec 21 22:11:21 2007
@@ -1,5 +1,5 @@
 /* -*- objc -*-
-  $Id: AquaSKKServer.mm,v 1.3 2006/12/17 15:05:41 t-suwa Exp $
+  $Id: AquaSKKServer.mm,v 1.4 2007/12/21 13:11:21 t-suwa Exp $
 
   MacOS X implementation of the SKK input method.
 
@@ -61,15 +61,13 @@
 
     NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
 
-    // Ž«‘‚Ì”z—ñ‚ðƒ[ƒh‚·‚é
-    NSArray* content = [[PreferencesController sharedController] contentForDictionarySet];
+    // ƒƒbƒZ[ƒWƒnƒ“ƒhƒ‰‚ð‹N“®‚·‚é
+    ServerMessageReceiver::start(kAquaSKKServerRunLoopMode);
 
     // Ž«‘ƒT[ƒo[‚ð‹N“®‚·‚é
+    NSArray* content = [[PreferencesController sharedController] contentForDictionarySet];
     DictionarySet::theInstance().Initialize((CFArrayRef)content);
 
-    // ƒƒbƒZ[ƒWƒnƒ“ƒhƒ‰‚ð‹N“®‚·‚é
-    ServerMessageReceiver::start(kAquaSKKServerRunLoopMode);
-
     // skkserv ƒGƒ~ƒ…ƒŒ[ƒVƒ‡ƒ“‚Ì‹N“®
     if([defaults boolForKey:KEY_skkserv_enabled]) {
 	skkserv::theInstance().start([defaults integerForKey:KEY_skkserv_port],
Index: AquaSKK/ChangeLog
diff -u AquaSKK/ChangeLog:1.56 AquaSKK/ChangeLog:1.57
--- AquaSKK/ChangeLog:1.56	Mon Dec 17 23:48:49 2007
+++ AquaSKK/ChangeLog	Fri Dec 21 22:11:21 2007
@@ -1,3 +1,10 @@
+2007-12-21  Tomotaka SUWA  <t.suw****@mac*****>
+
+	* AquaSKKServer.mm: 辞書サーバーの前にメッセージハンドラを初期化す
+	るように変更。
+
+	* DictionarySet.*: 辞書の初期化を非同期化。
+
 2007-12-17  Tomotaka SUWA  <t.suw****@mac*****>
 
 	* BIM.cpp: ASCII モード以外で HOME, END, HELP が効かない不具合を修
Index: AquaSKK/DictionarySet.cpp
diff -u AquaSKK/DictionarySet.cpp:1.9 AquaSKK/DictionarySet.cpp:1.10
--- AquaSKK/DictionarySet.cpp:1.9	Tue Jun 12 23:25:08 2007
+++ AquaSKK/DictionarySet.cpp	Fri Dec 21 22:11:21 2007
@@ -1,5 +1,5 @@
 /*
-  $Id: DictionarySet.cpp,v 1.9 2007/06/12 14:25:08 t-suwa Exp $
+  $Id: DictionarySet.cpp,v 1.10 2007/12/21 13:11:21 t-suwa Exp $
 
   MacOS X implementation of the SKK input method.
 
@@ -104,7 +104,17 @@
     return id.str();
 }
 
-void DictionarySet::load(CFArrayRef arrayRef) {
+void* DictionarySet::thread(void* param) {
+    DictionarySet* obj = reinterpret_cast<DictionarySet*>(param);
+
+    obj->load();
+
+    return 0;
+}
+
+void DictionarySet::load() {
+    Guard scope(async_);
+
     DictionaryContainer cache;
     DictionaryPref entry;
 
@@ -124,8 +134,8 @@
     }
 
     // 全ての辞書をキャッシュにロードする
-    for(CFIndex index = 0; index < CFArrayGetCount(arrayRef); ++ index) {
-	CFDictionaryRef dictRef = (CFDictionaryRef)CFRetain(CFArrayGetValueAtIndex(arrayRef, index));
+    for(CFIndex index = 0; index < CFArrayGetCount(arrayRef_); ++ index) {
+	CFDictionaryRef dictRef = (CFDictionaryRef)CFRetain(CFArrayGetValueAtIndex(arrayRef_, index));
 
 	// DictionaryPref を作る
 	entry.active = ((CFBooleanRef)CFDictionaryGetValue(dictRef, CFSTR("active")) == kCFBooleanTrue);
@@ -161,6 +171,8 @@
     // 辞書のキャッシュを入れ替える
     std::for_each(dicts_.begin(), dicts_.end(), DeleteDictionary());
     cache.swap(dicts_);
+
+    CFRelease(arrayRef_);
 }
 
 DictionarySet::DictionarySet() {
@@ -179,21 +191,32 @@
 }
 
 void DictionarySet::Initialize(CFArrayRef arrayRef) {
-    // 辞書をロードする
-    load(arrayRef);
+    Guard scope(async_);
+
+    arrayRef_ = (CFArrayRef)CFRetain(arrayRef);
+
+    pthread_t loader_;
+    pthread_create(&loader_, 0, DictionarySet::thread, this);
+    pthread_detach(loader_);
 }
 
 void DictionarySet::Terminate() {
+    Guard scope(async_);
+
     // 全ての辞書を削除する
     std::for_each(dicts_.begin(), dicts_.end(), DeleteDictionary());
     dicts_.clear();
 }
 
 std::string DictionarySet::CompleteEntry(const std::string& key, char result_delimiter) {
+    Guard scope(async_);
+
     return userdict_->findCompletions(key, result_delimiter);
 }
 
 std::string DictionarySet::FindOkuriAri(const std::string& key, const std::string& okuri, char result_delimiter) {
+    Guard scope(async_);
+
     SKKEntry strict_match = SKKEntry::CreateOkuriAri(key);
     SKKEntry normal_match = strict_match;
 
@@ -243,6 +266,8 @@
 }
 
 std::string DictionarySet::FindOkuriNasi(const std::string& key, char result_delimiter) {
+    Guard scope(async_);
+
     SKKEntry match = SKKEntry::CreateOkuriNasi(key);
 
     for(DictionaryPrefIterator iter = prefs_.begin(); iter != prefs_.end(); ++ iter) {
@@ -265,6 +290,8 @@
 }
 
 void DictionarySet::RegisterOkuriAri(const std::string& key, const std::string& okuri, const std::string& entry) {
+    Guard scope(async_);
+
     if(key.empty() || entry.empty() || okuri.empty()) {
 	std::cerr << "AquaSKK: Invalid registration received" << std::endl;
     } else {
@@ -273,6 +300,8 @@
 }
 
 void DictionarySet::RegisterOkuriNasi(const std::string& key, const std::string& entry) {
+    Guard scope(async_);
+
     // key だけチェックする(トグル変換の登録時は entry は空)
     if(key.empty()) {
 	std::cerr << "AquaSKK: Invalid registration received" << std::endl;
@@ -282,6 +311,8 @@
 }
 
 void DictionarySet::RemoveOkuriAri(const std::string& key, const std::string& entry) {
+    Guard scope(async_);
+
     if(key.empty() || entry.empty()) {
 	std::cerr << "AquaSKK: Invalid removal received" << std::endl;
     } else {
@@ -290,6 +321,8 @@
 }
 
 void DictionarySet::RemoveOkuriNasi(const std::string& key, const std::string& entry) {
+    Guard scope(async_);
+
     if(key.empty() || entry.empty()) {
 	std::cerr << "AquaSKK: Invalid removal received" << std::endl;
     } else {
Index: AquaSKK/DictionarySet.h
diff -u AquaSKK/DictionarySet.h:1.3 AquaSKK/DictionarySet.h:1.4
--- AquaSKK/DictionarySet.h:1.3	Mon Dec 18 00:05:41 2006
+++ AquaSKK/DictionarySet.h	Fri Dec 21 22:11:21 2007
@@ -1,5 +1,5 @@
 /* -*- c++ -*-
-  $Id: DictionarySet.h,v 1.3 2006/12/17 15:05:41 t-suwa Exp $
+  $Id: DictionarySet.h,v 1.4 2007/12/21 13:11:21 t-suwa Exp $
 
   MacOS X implementation of the SKK input method.
 
@@ -27,11 +27,14 @@
 #include <string>
 #include <vector>
 #include <map>
+#include "Mutex.h"
 
 class Dictionary;
 class UserDictionary;
 
 class DictionarySet {
+    Mutex async_;
+
     // 辞書の種類
     enum DictionaryTypes {
 	SKKDictionaryType = 10,
@@ -58,9 +61,12 @@
     DictionaryPrefContainer prefs_;
     DictionaryContainer dicts_;
 
+    CFArrayRef arrayRef_;
+
     Dictionary* createDictionary(const DictionaryPref& pref) const;
     std::string generateID(const DictionaryPref& pref) const;
-    void load(CFArrayRef arrayRef);
+    static void* thread(void* param);
+    void load();
 
     DictionarySet();
     ~DictionarySet();
Index: AquaSKK/Info-AquaSKKInputMethod.plist
diff -u AquaSKK/Info-AquaSKKInputMethod.plist:1.23 AquaSKK/Info-AquaSKKInputMethod.plist:1.24
--- AquaSKK/Info-AquaSKKInputMethod.plist:1.23	Mon Dec 17 23:48:49 2007
+++ AquaSKK/Info-AquaSKKInputMethod.plist	Fri Dec 21 22:11:21 2007
@@ -23,7 +23,7 @@
 	<key>CFBundleSignature</key>
 	<string>askk</string>
 	<key>CFBundleVersion</key>
-	<string>2007-12-17</string>
+	<string>2007-12-21</string>
 	<key>CSResourcesFileMapped</key>
 	<true/>
 	<key>tsInputMethodIconFileKey</key>
Index: AquaSKK/Info-AquaSKKServer.plist
diff -u AquaSKK/Info-AquaSKKServer.plist:1.23 AquaSKK/Info-AquaSKKServer.plist:1.24
--- AquaSKK/Info-AquaSKKServer.plist:1.23	Mon Dec 17 23:48:49 2007
+++ AquaSKK/Info-AquaSKKServer.plist	Fri Dec 21 22:11:21 2007
@@ -23,7 +23,7 @@
 	<key>CFBundleSignature</key>
 	<string>askk</string>
 	<key>CFBundleVersion</key>
-	<string>2007-12-17</string>
+	<string>2007-12-21</string>
 	<key>NSMainNibFile</key>
 	<string>Principal</string>
 	<key>NSPrincipalClass</key>


aquaskk-changes メーリングリストの案内
Back to archive index