Class: Quark::Quark::Concurrent::Queue
- Inherits:
-
DatawireQuarkCore::QuarkObject
- Object
- DatawireQuarkCore::QuarkObject
- Quark::Quark::Concurrent::Queue
- Defined in:
- lib/quark/concurrent.rb
Overview
A simple FIFO
Instance Attribute Summary collapse
-
#head ⇒ Object
Returns the value of attribute head.
-
#items ⇒ Object
Returns the value of attribute items.
-
#tail ⇒ Object
Returns the value of attribute tail.
Instance Method Summary collapse
- #__init_fields__ ⇒ Object
- #_getClass ⇒ Object
- #_getField(name) ⇒ Object
- #_setField(name, value) ⇒ Object
- #get ⇒ Object
-
#initialize ⇒ Queue
constructor
A new instance of Queue.
- #put(item) ⇒ Object
- #size ⇒ Object
Methods inherited from DatawireQuarkCore::QuarkObject
Constructor Details
#initialize ⇒ Queue
Returns a new instance of Queue.
525 526 527 528 529 530 531 532 533 |
# File 'lib/quark/concurrent.rb', line 525 def initialize() self.__init_fields__ (self).items = ::DatawireQuarkCore::List.new() (self).head = 0 (self).tail = 0 nil end |
Instance Attribute Details
#head ⇒ Object
Returns the value of attribute head.
521 522 523 |
# File 'lib/quark/concurrent.rb', line 521 def head @head end |
#items ⇒ Object
Returns the value of attribute items.
521 522 523 |
# File 'lib/quark/concurrent.rb', line 521 def items @items end |
#tail ⇒ Object
Returns the value of attribute tail.
521 522 523 |
# File 'lib/quark/concurrent.rb', line 521 def tail @tail end |
Instance Method Details
#__init_fields__ ⇒ Object
612 613 614 615 616 617 618 619 |
# File 'lib/quark/concurrent.rb', line 612 def __init_fields__() self.items = nil self.head = nil self.tail = nil nil end |
#_getClass ⇒ Object
574 575 576 577 578 579 |
# File 'lib/quark/concurrent.rb', line 574 def _getClass() return "quark.concurrent.Queue<quark.Object>" nil end |
#_getField(name) ⇒ Object
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/quark/concurrent.rb', line 581 def _getField(name) if ((name) == ("items")) return (self).items end if ((name) == ("head")) return (self).head end if ((name) == ("tail")) return (self).tail end return nil nil end |
#_setField(name, value) ⇒ Object
597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
# File 'lib/quark/concurrent.rb', line 597 def _setField(name, value) if ((name) == ("items")) (self).items = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List } end if ((name) == ("head")) (self).head = ::DatawireQuarkCore.cast(value) { ::Integer } end if ((name) == ("tail")) (self).tail = ::DatawireQuarkCore.cast(value) { ::Integer } end nil end |
#get ⇒ Object
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/quark/concurrent.rb', line 550 def get() item = ::DatawireQuarkCore.cast(nil) { ::Quark.T } if (((self).head) < ((self).tail)) item = ((self).items)[(self).head] (self).head = ((self).head) + (1) else if (((self).head) > (0)) (self).head = 0 (self).tail = 0 end end return item nil end |
#put(item) ⇒ Object
538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/quark/concurrent.rb', line 538 def put(item) if (((self).tail) < (((self).items).size)) ((self).items)[(self).tail] = (item) else ((self).items) << (item) end (self).tail = ((self).tail) + (1) nil end |
#size ⇒ Object
567 568 569 570 571 572 |
# File 'lib/quark/concurrent.rb', line 567 def size() return ((self).tail) - ((self).head) nil end |