X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f74123604bf09b2b5c68c5d48def74a2506099ff..4419ab41e208b813ab7ee7005de111fb23049a4f:/src/bindings/ruby/RubyProcess.rb diff --git a/src/bindings/ruby/RubyProcess.rb b/src/bindings/ruby/RubyProcess.rb index b2b981dd3d..113bf7cbb5 100644 --- a/src/bindings/ruby/RubyProcess.rb +++ b/src/bindings/ruby/RubyProcess.rb @@ -2,149 +2,114 @@ require 'msg' require 'Semaphore' include MSG -$debug = true # This is a Global Variable Useful for Debugging +$DEBUG = true # This is a Global Variable Useful for Debugging -class RbProcess < Thread - - - - +class RbProcess < Thread @@nextProcessId = 0 # Attributes attr_accessor :bind, :id, :proprieties, :name, :pargs, :schedBegin, :schedEnd - - -# Initialize - - - # Used in ApplicationHandler to Initialize it - - - +# Initialize : USED in ApplicationHandler to Initialize it def initialize(*args) - argc = args.size - - - -# Default Init +# Default Init***************************** No Args if argc == 0 #>>> new() super() { - @id = 0 @bind = 0 @name = "" @pargs = Array.new() - init_var() - - - - if $debug - puts "Init Default Initialzer..." - end - -# Thread.pass #yield ?!! + if $DEBUG + puts "Init Default Initialzer..." + end +# Thread.pass # sleep # Sleep Forever ... To Keep Thread Alive ?!! } end - # Initi with 2 arguments + # Init with 1 Argument ***********************>>Name( Not Used ) + if argc == 1 + super(){ + @name = args[0] + @pargs = Array.new() + init_var() + if $DEBUG + puts "Init with Name..." + end + } + end - if argc == 2 # >>>(HostName,Name) Or (Host , Name) + + + # Init with 2 arguments **********************>>>(HostName,Name) Or (Host , Name) + + if argc == 2 super(){ - - type = args[0].type() - if ( type.to_s == "String") host = Host.getByName(args[0]) end - if ( type.to_s == "MSG::Host") host = args[0] end - - - if $debug + if $DEBUG puts host end - - raise "Process Name Cannot Be Null" if args[1].empty? - @name = args[1] # First Arg - - if $debug + if $DEBUG puts @name end - - @pargs = Array.new() # No Args[] Passed in Arguments - - @@nextProcessId += 1 - @id = @@nextProcessId - - init_var() - - createProcess(self,host) #TODO >> MSG::Process - if $debug + @@nextProcessId += 1 + @id = @@nextProcessId + init_var() + createProcess(self,host) + if $DEBUG puts "Initilize with 2 args" end -# sleep # Keep The Thread Runin' +# sleep } end + + -# Init with 3 arguments + # Init with 3 arguments **********************(hostName,Name,args[]) or # (Host,Name,args[]) - if argc == 3 #(hostName,Name,args[]) or # (Host,Name,args[]) + if argc == 3 super(){ - type = args[0].type() - if( type.to_s == "String") -# host = Host.getByName(args[0]) - host ="Host.getByName(args[0])" + host =Host.getByName(args[0]) end - if ( type.to_s == "MSG::Host" ) host = args[0] end - - if $debug + if $DEBUG puts host end - raise "Process Name Cannot Be Null" if args[0].empty? - @name = args[1] - type = args[2].type() - raise "Third Argument Should be an Array" if type != "Array" - @pargs = args[3] - - @@nextProcessId +=1 @id = @@nextProcessId - init_var() - - createProcess(self,host) #TODO RubyMsg + createProcess(self,host) - if $debug + if $DEBUG puts "Initilize with 3 args" end @@ -160,7 +125,6 @@ class RbProcess < Thread def init_var() - @proprieties = Hash.new() # Process Synchronization Tools @schedBegin = Semaphore.new(0) @@ -178,13 +142,8 @@ class RbProcess < Thread return @@nextProcessId end - - - - - - - if $debug + + if $DEBUG #Process List def processList() @@ -218,8 +177,7 @@ class RbProcess < Thread end - - #get Own Name + #get Own Name def getName() @@ -249,9 +207,7 @@ class RbProcess < Thread end - - - # Stop + # Stop def unschedule() @@ -259,8 +215,7 @@ class RbProcess < Thread end - - #C Simualateur Process Equivalent Management + #C Simualateur Process Equivalent Management # After Binding Ruby Process to C Process # pause