Class: Synchronize
- Inherits:
-
Object
- Object
- Synchronize
- Defined in:
- lib/smsruby/adm_connection.rb
Overview
The Synchronize class contains all required variables to handle synchronization between producer - consumers and to protect critical resourses from concurrent access.
Instance Attribute Summary collapse
-
#empty ⇒ Object
Represent the condition variable for handling an empty queue “queue”.
-
#emptye ⇒ Object
Represent the condition variable for handling an empty queue “eq”.
-
#eq ⇒ Object
Reference a queue that contains destination numbers to wich the SMS messages couldn’t be send.
-
#full ⇒ Object
Represent the condition variable for handling a full queue “queue”.
-
#max ⇒ Object
Represent the max number of items that queue can retain.
-
#mutex ⇒ Object
Handle mutual exclution for queue.
-
#mutexe ⇒ Object
Handle mutual exclution for eq.
-
#mutexp ⇒ Object
Handle mutual exclution for the produced variable (protect the variable).
-
#queue ⇒ Object
Reference a queue that contains all produced items by the producer.
Instance Method Summary collapse
-
#count ⇒ Object
Get the number of items for the queue “queue”.
-
#initialize ⇒ Synchronize
constructor
initialize all variables for the class.
Constructor Details
#initialize ⇒ Synchronize
initialize all variables for the class
520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/smsruby/adm_connection.rb', line 520 def initialize @mutex = Mutex.new @mutexp=Mutex.new @mutexe=Mutex.new @empty = ConditionVariable.new @emptye = ConditionVariable.new @full = ConditionVariable.new @queue = Queue.new @eq = Queue.new @max = 10 end |
Instance Attribute Details
#empty ⇒ Object
Represent the condition variable for handling an empty queue “queue”
505 506 507 |
# File 'lib/smsruby/adm_connection.rb', line 505 def empty @empty end |
#emptye ⇒ Object
Represent the condition variable for handling an empty queue “eq”
507 508 509 |
# File 'lib/smsruby/adm_connection.rb', line 507 def emptye @emptye end |
#eq ⇒ Object
Reference a queue that contains destination numbers to wich the SMS messages couldn’t be send
513 514 515 |
# File 'lib/smsruby/adm_connection.rb', line 513 def eq @eq end |
#full ⇒ Object
Represent the condition variable for handling a full queue “queue”
509 510 511 |
# File 'lib/smsruby/adm_connection.rb', line 509 def full @full end |
#max ⇒ Object
Represent the max number of items that queue can retain
515 516 517 |
# File 'lib/smsruby/adm_connection.rb', line 515 def max @max end |
#mutex ⇒ Object
Handle mutual exclution for queue
499 500 501 |
# File 'lib/smsruby/adm_connection.rb', line 499 def mutex @mutex end |
#mutexe ⇒ Object
Handle mutual exclution for eq
503 504 505 |
# File 'lib/smsruby/adm_connection.rb', line 503 def mutexe @mutexe end |
#mutexp ⇒ Object
Handle mutual exclution for the produced variable (protect the variable)
501 502 503 |
# File 'lib/smsruby/adm_connection.rb', line 501 def mutexp @mutexp end |
#queue ⇒ Object
Reference a queue that contains all produced items by the producer
511 512 513 |
# File 'lib/smsruby/adm_connection.rb', line 511 def queue @queue end |
Instance Method Details
#count ⇒ Object
Get the number of items for the queue “queue”
535 536 537 |
# File 'lib/smsruby/adm_connection.rb', line 535 def count @queue.size end |