Multi threaded mirc scripting

Have a great tutorial that you want everyone to see? Post it here!

Moderators: IRC Operators, Support Team, mIRC Gurus

User avatar
Mpdreamz
User
User
Posts: 198
Joined: Sun Dec 10, 2006 12:07 pm
Contact:

Multi threaded mirc scripting

Postby Mpdreamz » Sun Dec 02, 2007 8:56 pm

Multi threaded mirc scripting

mIRC scripting scripting is totally single threaded! i.e if you issue a while command the script engine is locked up and unable to do anything else, read a more detailed description here.

Ok so that concludes this tutorial right ? well it would have been if it wasn't for a DLL called mThreads.dll by Narusegawa-Naru

this DLL allows you to call an alias from another thread without locking up mIRC.
Exactly what method it uses to do this i'm unsure since the dll is closed source but i imagine it uses the same principle by returning the message loop back to mIRC while it executes. So all the references to threads might not be completely technically accurate. However i remember Naru saying it actually created a new thread while i was beta testing this, all in all too dubious to dub this a definate "new" thread. The point is it works like a new thread and there's nothing dubious about that!

The linked zip comes with a demo script i changed the dllcall a bit myself since i didnt like the original one.

Code: Select all

alias calldll {
  var %Dll = $qt(C:\mThreads\mThreads.dll)
  return $dll(%dll,$2,$3-)
}

alias thread {
  var %data
  if ($isid) {
    if ($prop == count) %data = -i count
    elseif ($prop == create) %data = -c $1-
    elseif ($prop == version) return $calldll(mthreads,version,.)
    else %data = -i $1 $prop
  }
  else %data = $1-
  return $gettok($calldll(mthreads,thread,%data),2-,32)
}


Obviously change the path to the dll!

Ok so why is this dll so fantastic ?

Concider the following loop:

Code: Select all

alias someWhileLoop {
  var %x = 1
  while (%x < 1000000) inc %x
  return %x
}


To do a million iterations mIRC needs 13 seconds on my PC (2,4Ghz Quad Core). These whole 13 seconds mIRC is locked up and im unable to do anything.

By issuing this alias through a new thread i can continue to use mIRC while the while loop is busy

Code: Select all

alias testThread {
  thread -ca thread1 somewhileloop  $ticks
}
alias someWhileLoop {
  var %x = 1, %t = $1
  while (%x < 1000000) inc %x
  return %x itterations and took $calc($ticks - %t) ms
}


The return value is issued back to me trough a signal back to mIRC:

Code: Select all

on *:SIGNAL:THREADENDED:{
  echo -a thread $1 ended with exit code $2-
}


for me doing /testThread echo's back the following.

thread thread1 ended with exit code 1000000 itterations and took 13078 ms


All the while i was able to continue using mIRC. You can look at this method as doing an Asynchronous call sort of speak.

The number of threads you can create is machine specific so although you can create numerous concurrent running threads keep it reasonable!

So now you can do heavy processing in mIRC without worrying about locking up mIRC! (Think indexing files,searching big ass logs etc etc)


This concludes this simple tutorial, i might add more later on but i wanted to get the word out on this until now hidden DLL.

Happy exploring ;)
Lamer By profession

Check out my scripts!
User avatar
Foshizzle
User
User
Posts: 189
Joined: Thu Jul 12, 2007 7:53 pm
Location: Bill Gates Safe
Contact:

Postby Foshizzle » Sun Dec 02, 2007 9:05 pm

cool, thx.. ill use it for picwins
ImageImage
Image
Manacit2
User
User
Posts: 442
Joined: Fri Nov 24, 2006 2:39 am

Postby Manacit2 » Sun Dec 02, 2007 9:12 pm

EDIT: I got it working, but is there any way to make it eval more then one identifier or something?

IE: /thread -ca thread1 $de(bandup) $de(banddown) returns:
thread thread1 is ending with exit code 5.48
/thread -ca thread1 $de(banddown) $de(bandup) returns:
thread thread1 is ending with exit code 0.72
Last edited by Manacit2 on Sun Dec 02, 2007 9:22 pm, edited 1 time in total.
User avatar
kerst
User
User
Posts: 4514
Joined: Wed Dec 27, 2006 9:51 am
Location: #msl

Postby kerst » Sun Dec 02, 2007 9:16 pm

Manacit2 wrote:your test alias didn't work for me unfortunately... It didnt return anything (the while loop did however). and when I tried to do it myself I made mirc lock up and quit :(.


did you dload the dll and change the path?

looks amazing :o

ill try it tomorrow!

and foshizzle, you dont need it for picwins, they are quite fast, you just need the -n switch.

edit; for just the while loops, i think there is a whilefix.dll somewhere too :)
Last edited by kerst on Sun Dec 02, 2007 9:18 pm, edited 1 time in total.
Image
Steve's work

- Proscript -
R.I.P proscript
User avatar
Mpdreamz
User
User
Posts: 198
Joined: Sun Dec 10, 2006 12:07 pm
Contact:

Postby Mpdreamz » Sun Dec 02, 2007 9:17 pm

You need to download the DLL i linked too for the test alias to work :)

The while loop takes a while and locks up mIRC the DLL "fixes" this or any alias that might take a while.
Lamer By profession



Check out my scripts!
Manacit2
User
User
Posts: 442
Joined: Fri Nov 24, 2006 2:39 am

Postby Manacit2 » Sun Dec 02, 2007 9:23 pm

I forgot the on *:SIGNAL part :oops: but I edited, and have a question about it :p
Imk0tter
User
User
Posts: 241
Joined: Thu Mar 08, 2007 4:45 am

Postby Imk0tter » Thu Jul 10, 2008 7:42 am

Quick question.. How come when ever I call a thread with -ca, and echo $threads when the thread has ended, the number stays the same? Do those threads still exist? And can this lead to trouble?
Image
Rhino Cracker
Newbie
Newbie
Posts: 1
Joined: Fri Oct 23, 2015 1:09 am

Re: Multi threaded mirc scripting

Postby Rhino Cracker » Fri Oct 23, 2015 1:14 am

Hi all,

the file (mThreads.dll / *.zip containing it) disappeared from web.
Does anyone still have it and could upload it somewhere?

greetings, Rhino
User avatar
denny
User
User
Posts: 255
Joined: Fri Jun 26, 2009 7:15 pm
Location: #Unique

Re: Multi threaded mirc scripting

Postby denny » Fri Nov 13, 2015 12:10 am

Almost afraid to ask, but I'd like to have it too :)
Image
/invite Unique #

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 2 guests