aboutsummaryrefslogtreecommitdiff
path: root/src/set/gnunet-service-set.h
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-08-30 00:44:11 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-08-30 00:44:11 +0000
commit7936cab9bd741a9ff30362c8495daa29f1874b2e (patch)
tree33606962451dcb4b15dabff20f605a5c58f1cc72 /src/set/gnunet-service-set.h
parent38963d1e81332032e0ac774f4f2c6b804c38802a (diff)
downloadgnunet-7936cab9bd741a9ff30362c8495daa29f1874b2e.tar.gz
gnunet-7936cab9bd741a9ff30362c8495daa29f1874b2e.zip
work in progress: fix set bug, implement lazy copy
Diffstat (limited to 'src/set/gnunet-service-set.h')
-rw-r--r--src/set/gnunet-service-set.h121
1 files changed, 98 insertions, 23 deletions
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h
index 8d671ac81..d23291c82 100644
--- a/src/set/gnunet-service-set.h
+++ b/src/set/gnunet-service-set.h
@@ -211,6 +211,10 @@ typedef void
211(*CancelImpl) (struct Operation *op); 211(*CancelImpl) (struct Operation *op);
212 212
213 213
214typedef struct SetState *
215(*CopyStateImpl) (struct Set *op);
216
217
214/** 218/**
215 * Dispatch table for a specific set operation. Every set operation 219 * Dispatch table for a specific set operation. Every set operation
216 * has to implement the callback in this struct. 220 * has to implement the callback in this struct.
@@ -261,6 +265,30 @@ struct SetVT
261 * Callback for canceling an operation by its ID. 265 * Callback for canceling an operation by its ID.
262 */ 266 */
263 CancelImpl cancel; 267 CancelImpl cancel;
268
269 CopyStateImpl copy_state;
270};
271
272
273/**
274 * MutationEvent gives information about changes
275 * to an element (removal / addition) in a set content.
276 */
277struct MutationEvent
278{
279 /**
280 * First generation affected by this mutation event.
281 *
282 * If @a generation is 0, this mutation event is a list
283 * sentinel element.
284 */
285 unsigned int generation;
286
287 /**
288 * If @a added is #GNUNET_YES, then this is a
289 * `remove` event, otherwise it is an `add` event.
290 */
291 int added;
264}; 292};
265 293
266 294
@@ -285,22 +313,17 @@ struct ElementEntry
285 struct GNUNET_HashCode element_hash; 313 struct GNUNET_HashCode element_hash;
286 314
287 /** 315 /**
288 * Generation the element was added by the client. 316 * If @a mutations is not NULL, it contains
289 * Operations of earlier generations will not consider the element. 317 * a list of mutations, ordered by increasing generation.
290 */ 318 * The list is terminated by a sentinel event with `generation`
291 unsigned int generation_added; 319 * set to 0.
292 320 *
293 /** 321 * If @a mutations is NULL, then this element exists in all generations
294 * Generation the element was removed by the client. 322 * of the respective set content this element belongs to.
295 * Operations of later generations will not consider the element.
296 * Only valid if @e removed is #GNUNET_YES.
297 */ 323 */
298 unsigned int generation_removed; 324 struct MutationEvent *mutations;
299 325
300 /** 326 unsigned int mutations_size;
301 * #GNUNET_YES if the element has been removed in some generation.
302 */
303 int removed;
304 327
305 /** 328 /**
306 * #GNUNET_YES if the element is a remote element, and does not belong 329 * #GNUNET_YES if the element is a remote element, and does not belong
@@ -323,12 +346,12 @@ struct Operation
323 const struct SetVT *vt; 346 const struct SetVT *vt;
324 347
325 /** 348 /**
326 * Tunnel to the peer. 349 * Channel to the peer.
327 */ 350 */
328 struct GNUNET_CADET_Channel *channel; 351 struct GNUNET_CADET_Channel *channel;
329 352
330 /** 353 /**
331 * Message queue for the tunnel. 354 * Message queue for the channel.
332 */ 355 */
333 struct GNUNET_MQ_Handle *mq; 356 struct GNUNET_MQ_Handle *mq;
334 357
@@ -366,7 +389,7 @@ struct Operation
366 * Timeout task, if the incoming peer has not been accepted 389 * Timeout task, if the incoming peer has not been accepted
367 * after the timeout, it will be disconnected. 390 * after the timeout, it will be disconnected.
368 */ 391 */
369 struct GNUNET_SCHEDULER_Task * timeout_task; 392 struct GNUNET_SCHEDULER_Task *timeout_task;
370 393
371 /** 394 /**
372 * Unique request id for the request from a remote peer, sent to the 395 * Unique request id for the request from a remote peer, sent to the
@@ -397,6 +420,41 @@ struct Operation
397 420
398 421
399/** 422/**
423 * SetContent stores the actual set elements,
424 * which may be shared by multiple generations derived
425 * from one set.
426 */
427struct SetContent
428{
429 /**
430 * Number of references to the content.
431 */
432 unsigned int refcount;
433
434 /**
435 * Maps `struct GNUNET_HashCode *` to `struct ElementEntry *`.
436 */
437 struct GNUNET_CONTAINER_MultiHashMap *elements;
438
439 unsigned int latest_generation;
440};
441
442
443struct GenerationRange
444{
445 /**
446 * First generation that is excluded.
447 */
448 unsigned int start;
449
450 /**
451 * Generation after the last excluded generation.
452 */
453 unsigned int end;
454};
455
456
457/**
400 * A set that supports a specific operation with other peers. 458 * A set that supports a specific operation with other peers.
401 */ 459 */
402struct Set 460struct Set
@@ -444,11 +502,6 @@ struct Set
444 struct GNUNET_CONTAINER_MultiHashMapIterator *iter; 502 struct GNUNET_CONTAINER_MultiHashMapIterator *iter;
445 503
446 /** 504 /**
447 * Maps `struct GNUNET_HashCode *` to `struct ElementEntry *`.
448 */
449 struct GNUNET_CONTAINER_MultiHashMap *elements;
450
451 /**
452 * Evaluate operations are held in a linked list. 505 * Evaluate operations are held in a linked list.
453 */ 506 */
454 struct Operation *ops_head; 507 struct Operation *ops_head;
@@ -460,11 +513,18 @@ struct Set
460 513
461 /** 514 /**
462 * Current generation, that is, number of previously executed 515 * Current generation, that is, number of previously executed
463 * operations on this set 516 * operations and lazy copies on the underlying set content.
464 */ 517 */
465 unsigned int current_generation; 518 unsigned int current_generation;
466 519
467 /** 520 /**
521 * List of generations we have to exclude, due to lazy copies.
522 */
523 struct GenerationRange *excluded_generations;
524
525 unsigned int excluded_generations_size;
526
527 /**
468 * Type of operation supported for this set 528 * Type of operation supported for this set
469 */ 529 */
470 enum GNUNET_SET_OperationType operation; 530 enum GNUNET_SET_OperationType operation;
@@ -475,6 +535,12 @@ struct Set
475 */ 535 */
476 uint16_t iteration_id; 536 uint16_t iteration_id;
477 537
538 /**
539 * Content, possibly shared by multiple sets,
540 * and thus reference counted.
541 */
542 struct SetContent *content;
543
478}; 544};
479 545
480 546
@@ -510,4 +576,13 @@ const struct SetVT *
510_GSS_intersection_vt (void); 576_GSS_intersection_vt (void);
511 577
512 578
579int
580_GSS_is_element_of_set (struct ElementEntry *ee,
581 struct Set *set);
582
583int
584_GSS_is_element_of_operation (struct ElementEntry *ee,
585 struct Operation *op);
586
587
513#endif 588#endif