releasing/cbrtools/perl/CommandController.pm
author kelvzhu
Mon, 18 Oct 2010 16:16:46 +0800
changeset 655 3f65fd25dfd4
parent 602 3145852acc89
permissions -rw-r--r--
sync up SVN codes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
602
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     1
# Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     2
# All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     3
# This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     5
# which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     7
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     8
# Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    10
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    11
# Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    12
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    13
# Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    14
# 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    15
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    16
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    17
package CommandController;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    18
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    19
use strict;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    20
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    21
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    22
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    23
# Constants.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    24
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    25
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    26
use constant READER_SEMAPHORE_NAME => "CommandControllerReaderSemaphore_";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    27
use constant WRITER_SEMAPHORE_NAME => "CommandControllerWriterSemaphore_";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    28
use constant MAX_NUM_CONCURRENT_READERS => 100;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    29
use constant CMD_INDEPENDANT => 0; # Commands that can be run regardless of what else is running.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    30
use constant CMD_ENV_READER => 1;  # Commands that only read the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    31
use constant CMD_ENV_WRITER => 2;  # Commands that modify the environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    32
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    33
my %commandInfo = (
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    34
 		   EnvMembership => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    35
		   CleanRemote => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    36
		   ExportEnv => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    37
		   ExportRel => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    38
		   CopyRel => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    39
		   ImportEnv => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    40
		   ImportRel => CMD_INDEPENDANT,		
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    41
		   LatestVer => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    42
		   PullEnv => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    43
		   PushEnv => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    44
		   PushRel => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    45
		   PullRel => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    46
		   DeltaEnv => CMD_INDEPENDANT,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    47
		   BinInfo => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    48
		   SourceInfo => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    49
		   DiffEnv => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    50
		   DiffRel => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    51
		   ModNotes => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    52
		   ViewNotes => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    53
		   BuildRel => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    54
		   EnvSize => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    55
		   MakeSnapShot => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    56
		   CleanEnv => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    57
		   EnvInfo => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    58
		   GetEnv => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    59
		   GetRel => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    60
		   GetSource => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    61
		   InstallSnapShot => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    62
		   MakeEnv => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    63
		   MakeRel => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    64
		   RemoveRel => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    65
		   RemoveSource => CMD_ENV_READER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    66
		   PrepEnv => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    67
		   PrepRel => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    68
		   ValidateEnv => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    69
		   ValidateRel => CMD_ENV_WRITER,
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    70
		   EnvData => CMD_ENV_WRITER
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    71
		  );
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    72
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    73
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    74
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    75
# Public.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    76
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    77
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    78
sub New {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    79
  my $pkg = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    80
  my $self = {};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    81
  bless $self, $pkg;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    82
  $self->{iniData} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    83
  $self->{command} = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    84
  unless ($self->{iniData}->Win32ExtensionsDisabled()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    85
    $self->OpenSemaphores();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    86
    unless ($self->CanRun()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    87
      die "Error: Cannot run $self->{command} because another command is already running\n";
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    88
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    89
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    90
  return $self;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    91
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    92
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    93
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    94
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    95
# Private.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    96
#
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    97
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    98
sub CanRun {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
    99
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   100
  $self->{canRun} = 0;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   101
  my $commandType = $self->CommandType();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   102
  if ($commandType == CMD_INDEPENDANT) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   103
    $self->{canRun} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   104
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   105
  elsif ($commandType == CMD_ENV_READER) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   106
    unless ($self->WriterRunning()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   107
      $self->{canRun} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   108
      $self->IncReadersRunning();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   109
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   110
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   111
  elsif ($commandType == CMD_ENV_WRITER) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   112
    if (($self->NumReadersRunning() == 0) and not $self->WriterRunning()) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   113
      $self->{canRun} = 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   114
      $self->SetWriterRunning();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   115
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   116
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   117
  return $self->{canRun};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   118
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   119
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   120
sub DESTROY {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   121
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   122
  if ($self->{canRun}) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   123
    my $commandType = $self->CommandType();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   124
    if ($commandType == CMD_INDEPENDANT) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   125
      # Nothing to do.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   126
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   127
    elsif ($commandType == CMD_ENV_READER) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   128
      $self->DecReadersRunning();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   129
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   130
    elsif ($commandType == CMD_ENV_WRITER) {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   131
      $self->ClearWriterRunning();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   132
    }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   133
  }
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   134
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   135
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   136
sub OpenSemaphores {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   137
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   138
  my $currentEnvironment = Utils::CurrentDriveLetter() . lc(Utils::EpocRoot());
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   139
  $currentEnvironment =~ s/[:\\\/]+/_/g; # Can't have slashes in semaphore name
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   140
  
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   141
  require Win32::Semaphore;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   142
  # No longer 'use', as that fails with some versions of Perl
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   143
  $self->{writerSemaphore} = Win32::Semaphore->new(0, 2, WRITER_SEMAPHORE_NAME . $currentEnvironment) or die; # 2 because when counting the semaphore, it need to be incremented and then decremented (release(0, $var) doesn't work).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   144
  $self->{readerSemaphore} = Win32::Semaphore->new(0, MAX_NUM_CONCURRENT_READERS, READER_SEMAPHORE_NAME . $currentEnvironment) or die;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   145
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   146
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   147
sub CommandType {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   148
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   149
  die unless exists $commandInfo{$self->{command}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   150
  return $commandInfo{$self->{command}};
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   151
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   152
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   153
sub WriterRunning {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   154
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   155
  my $writerRunning = SemaphoreCount($self->{writerSemaphore});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   156
  die if $writerRunning > 1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   157
  return $writerRunning;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   158
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   159
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   160
sub SetWriterRunning {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   161
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   162
  SemaphoreInc($self->{writerSemaphore});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   163
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   164
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   165
sub ClearWriterRunning {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   166
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   167
  SemaphoreDec($self->{writerSemaphore});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   168
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   169
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   170
sub NumReadersRunning {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   171
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   172
  return SemaphoreCount($self->{readerSemaphore});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   173
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   174
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   175
sub IncReadersRunning {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   176
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   177
  SemaphoreInc($self->{readerSemaphore});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   178
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   179
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   180
sub DecReadersRunning {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   181
  my $self = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   182
  SemaphoreInc($self->{readerSemaphore});
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   183
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   184
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   185
sub SemaphoreCount {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   186
  my $semaphore = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   187
  my $count;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   188
  $semaphore->release(1, $count) or die;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   189
  $semaphore->wait();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   190
  return $count;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   191
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   192
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   193
sub SemaphoreInc {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   194
  my $semaphore = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   195
  $semaphore->release(1) or die;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   196
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   197
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   198
sub SemaphoreDec {
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   199
  my $semaphore = shift;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   200
  $semaphore->wait();
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   201
}
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   202
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   203
1;
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   204
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   205
=head1 NAME
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   206
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   207
CommandController.pm - Provides a means of controlling which commands can run concurrently within a single environment.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   208
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   209
=head1 DESCRIPTION
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   210
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   211
Certain commands can reliably be run while others are running, whereas others must be run in isolation. This class has responsibility for defining a set of rules regarding concurrent running of commands and ensuring that they are followed. Each command is classified into one of three types:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   212
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   213
=over 4
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   214
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   215
=item 1 Independant
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   216
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   217
Commands of this type can be run regardless of whatever else may also be running at the time because they neither read nor modify the environment. Commands of this type:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   218
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   219
 		   EnvMembership
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   220
		   CleanRemote
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   221
		   ExportEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   222
		   ExportRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   223
		   ImportEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   224
		   ImportRel		
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   225
		   LatestVer
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   226
		   PullEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   227
		   PullRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   228
		   PushEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   229
		   PushRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   230
		   DeltaEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   231
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   232
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   233
=item 2 Environment readers
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   234
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   235
Commands of this type can be run provided there aren't any writers running. Commands of this type:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   236
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   237
		   BinInfo
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   238
		   DiffEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   239
		   DiffRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   240
                   MakeSnapShot
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   241
		   ModNotes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   242
                   RemoveSource
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   243
		   ViewNotes
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   244
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   245
=item 3 Environment writers
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   246
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   247
Commands of this type may modify the state of the environment, and so may only run providing there are no other writers or readers running. Commands of this type:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   248
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   249
		   CleanEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   250
		   EnvInfo
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   251
		   GetEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   252
		   GetRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   253
		   GetSource
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   254
                   InstallSnapShot
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   255
		   MakeEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   256
		   MakeRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   257
		   RemoveRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   258
		   PrepEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   259
		   PrepRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   260
		   ValidateEnv
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   261
		   ValidateRel
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   262
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   263
=back
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   264
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   265
To enforce these runs, multiple instances of C<CommandController> (running in different processes) need to know what else is running at any particular point in time. This information could have been stored in a file, but this has the significant problem that commands that are prematurely killed by the user (perhaps by hitting ctrl-c), they will not cleanup after themselves and so the environment could get stuck in an invalid state. To avoid this problem, a pair of Win32 semaphores are used to count the number of readers and writers currently active at any point in time. Note, only the counting properties of the semaphores are used, which is somewhat unusual (normally semaphores are used to control the execution of threads). The advantage of this scheme is that even if a command is prematurely killed by the user, its handles to the semaphoreswill be released. This may mean that for a period of time the semaphores may have invalid value, but once all commands that are currently running have completed, the semaphores will be destroyed (kernel side) and the environment is guaranteed of being in a 'ready to run' state.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   266
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   267
=head1 INTERFACE
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   268
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   269
=head2 New
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   270
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   271
Expects to be passed an C<IniData> reference and the name of the command that is about to be run (this is case sensitive). Creates and returns a new C<CommandController> instance if the command if free to run. Dies if not. The C<IniData> reference is used to determine if Win32 extensions have been disabled. If this is the case then the check to see if this command is free to run is not done (since doing so relies on Win32 functionality).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   272
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   273
=head1 KNOWN BUGS
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   274
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   275
None.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   276
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   277
=head1 COPYRIGHT
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   278
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   279
 Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   280
 All rights reserved.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   281
 This component and the accompanying materials are made available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   282
 under the terms of the License "Eclipse Public License v1.0"
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   283
 which accompanies this distribution, and is available
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   284
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   285
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   286
 Initial Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   287
 Nokia Corporation - initial contribution.
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   288
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   289
 Contributors:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   290
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   291
 Description:
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   292
 
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   293
3145852acc89 add releasing to new structure
jjkang
parents:
diff changeset
   294
=cut