| 1131 | } |
| 1132 | |
| 1133 | function insDocument(self) { |
| 1134 | |
| 1135 | if (!self.ready || self.states.insert || !self.pending.insert.length || F.isKilled) |
| 1136 | return; |
| 1137 | |
| 1138 | var doc = self.pending.insert.shift(); |
| 1139 | if (doc) { |
| 1140 | |
| 1141 | var cls = self.$classes[doc.name]; |
| 1142 | if (cls == null) { |
| 1143 | doc.callback(new Error('GraphDB: Class "{0}" not found.'.format(doc.name))); |
| 1144 | return; |
| 1145 | } |
| 1146 | |
| 1147 | if (cls.locked || !cls.ready) { |
| 1148 | self.pending.insert.push(doc); |
| 1149 | setTimeout(self.cb_next, DELAY, NEXT_INSERT); |
| 1150 | return; |
| 1151 | } |
| 1152 | |
| 1153 | self.states.insert = true; |
| 1154 | |
| 1155 | addDocument(self, cls, doc.value, function(err, id) { |
| 1156 | // setTimeout(insDocument, 100, self); |
| 1157 | self.states.insert = false; |
| 1158 | setImmediate(insDocument, self); |
| 1159 | doc.callback(err, id); |
| 1160 | }); |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | function updDocument(self) { |
| 1165 | |