Lasso Soft Inc. > Home

[mv_findThread]

Linkmv_findThread
AuthorMarc Vos
CategoryThreads
Version8.5.x
LicensePublic Domain
Posted27 Aug 2010
Updated27 Aug 2010
More by this author...

Description

This tag either returns an array of maps with found thread data or simply true or false. This way you can check if a Lasso process is already running. It searches for the given string in the thread_name field.

Sample Usage

[
mv_findThread('smtp', 'M', 'Y');'
'; mv_findThread('smtp', 'X', 'Y');'
'; mv_findThread('smtp', 'N', 'Y');'
'; if (mv_findThread('/process', 'X', 'Y'));  log_critical('Process X already running');  abort; /if; ]

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_tag('mv_findThread', -required='Name', -copy, -optional='current', -copy, -optional='signal', -copy);
/* current:
  M = Mark the array entry as being the calling thread.  X = eXclude the calling thread from the checks and the result list / signal.  any = Include calling thread in checks and result list without markings.
 signal:		
  Y = simply return true or false instead of a list with found threads.*/
 local(
  'tList' = array,
  'curID' = thread_getcurrentid,
  'insert'= false
 );

	// Set default value to M(ark)
 if(! local_defined('current'));
  local('current') = 'M';
 /if;

	// Set default value to N(o)
 if(! local_defined('signal'));
  local('signal') = 'N';
 /if;

 iterate(Thread_List, local('tmp'));
  #tmp = Thread_Info(#tmp);
  if (#tmp->find('name') >> #name);
   #insert=false;

   if(#tmp->find('id') >> #curID);
    if(#current == 'M');
     #tmp->insert('isMe'='Y');
     #insert=true;
    else(#current != 'X');
     #insert=true;
    /if;
   else;
    #insert=true;
   /if;

   if(#insert);
    if(#signal == 'Y');
     loop_abort;
    /if;
    #tList->insert(#tmp);
   /if;
  /if;
 /iterate;

 if(#signal == 'Y');
  return(#insert);
 else;
  return(#tList);
 /if;

/define_tag;

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft