Friday, December 27, 2019

Delphi Thread Pool Example Using AsyncCalls

This is my next test project to see what threading library for Delphi would suite me best for my file scanning task I would like to process in multiple threads / in a thread pool. To repeat my goal: transform my sequential file scanning of 500-2000 files from the non threaded approach to a threaded one. I should not have 500 threads running at one time, thus would like to use a thread pool. A thread pool is a queue-like class feeding a number of running threads with the next task from the queue. The first (very basic) attempt was made by simply extending the TThread class and implementing the Execute method (my threaded string parser). Since Delphi does not have a thread pool class implemented out of the box, in my second attempt Ive tried using OmniThreadLibrary by Primoz Gabrijelcic. OTL is fantastic, has zillion ways to run a task in a background, a way to go if you want to have fire-and-forget approach to handing threaded execution of pieces of your code. AsyncCalls by Andreas Hausladen Note: what follows would be more easy to follow if you first download the source code. While exploring more ways to have some of my functions executed in a threaded manner Ive decided to also try the AsyncCalls.pas unit developed by Andreas Hausladen. Andys AsyncCalls – Asynchronous function calls unit is another library a Delphi developer can use to ease the pain of implementing threaded approach to executing some code. From Andys blog: With AsyncCalls you can execute multiple functions at the same time and synchronize them at every point in the function or method that started them. ... The AsyncCalls unit offers a variety of function prototypes to call asynchronous functions. ... It implements a thread pool! The installation is super easy: just use asynccalls from any of your units and you have instant access to things like execute in a separate thread, synchronize main UI, wait until finished. Beside the free to use (MPL license) AsyncCalls, Andy also frequently publishes his own fixes for the Delphi IDE like Delphi Speed Up and DDevExtensions Im sure youve heard of (if not using already). AsyncCalls In Action In essence, all AsyncCall functions return an IAsyncCall interface that allows to synchronize the functions. IAsnycCall exposes the following methods: //v 2.98 of asynccalls.pas IAsyncCall interface //waits until the function is finished and returns the return value function Sync: Integer; //returns True when the asynchron function is finished function Finished: Boolean; //returns the asynchron functions return value, when Finished is TRUE function ReturnValue: Integer; //tells AsyncCalls that the assigned function must not be executed in the current threa procedure ForceDifferentThread; end; Heres an example call to a method expecting two integer parameters (returning an IAsyncCall): TAsyncCalls.Invoke(AsyncMethod, i, Random(500)); function TAsyncCallsForm.AsyncMethod(taskNr, sleepTime: integer): integer;begin result : sleepTime; Sleep(sleepTime); TAsyncCalls.VCLInvoke( procedure begin Log(Format(done nr: %d / tasks: %d / slept: %d, [tasknr, asyncHelper.TaskCount, sleepTime])); end);end; The TAsyncCalls.VCLInvoke is a way to do synchronization with your main thread (applications main thread - your application user interface). VCLInvoke returns immediately. The anonymous method will be executed in the main thread. Theres also VCLSync which returns when the anonymous method was called in the main thread. Thread Pool in AsyncCalls Back to my file scanning task: when feeding (in a for loop) the asynccalls thread pool with series of TAsyncCalls.Invoke() calls, the tasks will be added to internal the pool and will get executed when time comes (when previously added calls have finished). Wait All IAsyncCalls To Finish The AsyncMultiSync function defined in asnyccalls waits for the async calls (and other handles) to finish. There are a few overloaded ways to call AsyncMultiSync, and heres the simplest one: function AsyncMultiSync(const List: array of IAsyncCall; WaitAll: Boolean True; Milliseconds: Cardinal INFINITE): Cardinal; If I want to have wait all implemented, I need to fill in an array of IAsyncCall and do AsyncMultiSync in slices of 61. My AsnycCalls Helper Heres a piece of the TAsyncCallsHelper: WARNING: partial code! (full code available for download)uses AsyncCalls;type TIAsyncCallArray array of IAsyncCall; TIAsyncCallArrays array of TIAsyncCallArray; TAsyncCallsHelper class private fTasks : TIAsyncCallArrays; property Tasks : TIAsyncCallArrays read fTasks; public procedure AddTask(const call : IAsyncCall); procedure WaitAll; end; WARNING: partial code!procedure TAsyncCallsHelper.WaitAll;var i : integer;begin for i : High(Tasks) downto Low(Tasks) do begin AsyncCalls.AsyncMultiSync(Tasks[i]); end;end; This way I can wait all in chunks of 61 (MAXIMUM_ASYNC_WAIT_OBJECTS) - i.e. waiting for arrays of IAsyncCall. With the above, my main code to feed the thread pool looks like: procedure TAsyncCallsForm.btnAddTasksClick(Sender: TObject);const nrItems 200;var i : integer;begin asyncHelper.MaxThreads : 2 * System.CPUCount; ClearLog(starting); for i : 1 to nrItems do begin asyncHelper.AddTask(TAsyncCalls.Invoke(AsyncMethod, i, Random(500))); end; Log(all in); //wait all //asyncHelper.WaitAll; //or allow canceling all not started by clicking the Cancel All button: while NOT asyncHelper.AllFinished do Application.ProcessMessages; Log(finished);end; Cancel all? - Have To Change The AsyncCalls.pas :( I would also like to have a way of cancelling those tasks that are in the pool but are waiting for their execution. Unfortunately, the AsyncCalls.pas does not provide a simple way of canceling a task once it has been added to the thread pool. Theres no IAsyncCall.Cancel or IAsyncCall.DontDoIfNotAlreadyExecuting or IAsyncCall.NeverMindMe. For this to work I had to change the AsyncCalls.pas by trying to alter it as less as possible - so that when Andy releases a new version I only have to add a few lines to have my Cancel task idea working. Heres what I did: Ive added a procedure Cancel to the IAsyncCall. The Cancel procedure sets the FCancelled (added) field which gets checked when the pool is about to start executing the task. I needed to slightly alter the IAsyncCall.Finished (so that a call reports finished even when cancelled) and the TAsyncCall.InternExecuteAsyncCall procedure (not to execute the call if it has been cancelled). You can use WinMerge to easily locate differences between Andys original asynccall.pas and my altered version (included in the download). You can download the full source code and explore. Confession NOTICE! :) The CancelInvocation method stopps the AsyncCall from being invoked. If the AsyncCall is already processed, a call to CancelInvocation has no effect and the Canceled function will return False as the AsyncCall wasnt canceled.The Canceled method returns True if the AsyncCall was canceled by CancelInvocation.The Forget method unlinks the IAsyncCall interface from the internal AsyncCall. This means that if the last reference to the IAsyncCall interface is gone, the asynchronous call will be still executed. The interfaces methods will throw an exception if called after calling Forget. The async function must not call into the main thread because it could be executed after the TThread.Synchronize/Queue mechanism was shut down by the RTL what can cause a dead lock. Note, though, that you can still benefit from my AsyncCallsHelper if you need to wait for all async calls to finish with asyncHelper.WaitAll; or if you need to CancelAll.

Thursday, December 19, 2019

The Importance of a Single Authorship of Isaiah - 1570 Words

INTRODUCTION The Importance of a Single Authorship of Isaiah When a critic attacks the authorship of Isaiah, it is like the â€Å"devil† putting his foot in the door. Modern criticism has cast doubt on the Bible. The written Word of God is a battlefield and many a skeptic has tried to dethrone the Bible claiming it is just another book. Denying a single authorship of Isaiah: 1. Casts doubt on the written Word of God 2. Makes Jesus appear ignorant when He said Isaiah wrote the scroll of Isaiah 3. Promotes skepticism about the authorship of other books 4. Makes Paul appear ignorant in quoting from Isaiah 5. Makes New Testament writers appear ignorant quoting from Isaiah A Brief Overview of the Book of Isaiah As a whole, Isaiah can be divided into three main parts: Isaiah 1-35 – describes Messiah as a mighty Ruler and King Isaiah 36-39 – relates to the times of Hezekiah Isaiah 40-66 – describes the Messiah as the meek and lowly Servant of the LORD Some scholars feel that Isaiah 1-35 and Isaiah 40-66 must be works of different authors. The first part of Isaiah reveals a Messiah who is a mighty Ruler and King. The last part of Isaiah reveals a meek and lowly Messiah who is a suffering victim. This shift from â€Å"a mighty ruler† to â€Å"a suffering victim,† make some critics feel there are at least two authors to Isaiah. Other critics claim that certain portions of Isaiah 13:24-27 and certain verses in Isaiah 14 and 21 were also written by someone other than Isaiah. Therefore, according toShow MoreRelatedThe Foundations Of The Canons1702 Words   |  7 Pagestype of written text that would be foundational therefore no one would want to take away or add to it. The early church was using the four Gospels and the letters of many of the Apostles in their church teachings. The churches focused on the importance of the authors being in a first-hand relationship or direct correlation to a disciple such as Mark was to Peter and Luke was to Paul (). The Apostles took some time to write down their experiences because during that time many were illiterate andRead MoreEssay on Encountering the Old Testament2615 Words   |  11 Pagesare stories, prophecy, parables, and poetry. Interpret Figurative Language Just as we do today, the prophets of the Old Testament used figurative language to convey meaning. One example of this is â€Å"The trees of the field will clap their hands† in Isaiah 55:12. Let Scripture Interpret Scripture Sometimes we find that one passage of Scripture will contradict another passage of Scripture. When this occurs we should find a different passage that presents clear teaching on the topic and interpret theRead MoreIntroduction to Christian Thought Essay9122 Words   |  37 Pagesheard Christ calling Himself the â€Å"Son of Man†? Messiah The Deity of Christ - Pg. 155-160 1. T/F Jesus Christ is the second member of the trinity, is equal with the father in nature and yet submissive in duty. T 2. T/F Christ was a single and undivided personality. T 3. T/F Jesus claimed to be one with the father. T 4. T/F Jesus claimed to have the ability to forgive sins. T 5. T/F Jesus allowed people to worship him. T 6. T/F Jesus claimed to have omnipresence, omniscience

Wednesday, December 11, 2019

Is Your Organization Ready To Consider An HRMS Essay Example For Students

Is Your Organization Ready To Consider An HRMS? Essay Before you look at acquiring an HRMS, look inside your organization. How intrinsic to your companys strategic direction is the acquisition of an HRMS? What is the meaning of an HRMS to your executives? Are they convinced of the strategic importance of HR? Or will your executives views be limited to an HRMS with only basic record keeping functions (such as demographics data or payroll information)? Your success in obtaining strong executive sponsorship will dictate where you look and what package you will select. You will need to consider the overall budget. Who needs to be on side to develop a credible business case?What about technology? Is your organization ready to consider solutions that allow widespread web access? What impact would technology have on external organizations like employee groups? Should they be brought on board early in the cycle?Finally, competing projects may impede your executives consideration of thisproject. Your companys resources may be fully engaged in other initiatives. This will affect your overall timeline. What Functionality Do You Need?There are many options. Basic HRMS include payroll applications with little or noHR functionality. Comprehensive systems include payroll and may include compensation, benefits, positions, health and safety, training and development, and time and labour. In addition to raw function, some packages make it easier to do your job by offering workflow capability. For example, an email message can be automatically triggered to a benefit administrator to enroll an employee on benefits when an applicant ishired. Others have non-traditional ways of accessing information: for example, Interactive Voice Response (IVR) married to workflow can trigger actions like job scheduling. Alternatively, your organization may want to use a kiosk to enable employees to access and update their own personnel information. To determine your scope, your organization should go through a requirements. study or needs analysis. Consider where the payroll system fits in. Should you track detailed payroll records in your financial system? Do you have extensive requirements in the areas of pension administration?Considering both present HR activities and future directions of HR in your organization, list ten case studies that will give you the greatest return on investment. For help with creating the case studies, obtain the HR Matrix available from HRMS Directions or the International Association for Human Resource Information Management (IHRIM). By relating your case studies to return on investment, you can avoid being distracted by insignificant items in vendor demonstrations. Remember to consult with individuals within and outside of the HR functional area to develop your detailed case studies. Other users across the organization may have systems or even desktop applications that will be replaced by this package. If needed, hold facilitated sessions to draw on the experiences and ideas of individuals throughout your organization. Finally, consider whether your case studies rigidly mirror current practice, or area reflective of ways you might consider addressing the target business processes.You want the latter. But What About the Technology?Involve your information technology (IT) group early in your requirements discussions. While they may not be interested in the detailed case studies, they will be interested in the application usage. For example, how many potential users will be accessing the software at the same time? What platform will the software run on? How compatible is it with current technology? If you are considering web access to information, this may mean significant changes to your IT environment. What are the interfaces to the system? Will the HRMS package need to supply data to or receive data from any other systems?Still Is an Implementation Feasible? The Hot Buttons:Resources Based on the application you choose, look at your companys resources to determine whether you are likely to have both the people and the skills available in-house when you will need them. Senior staff who best understand the business area and individuals with implementation experience will need to b e part of your team. Project roles will depend on project size and scope and will include, for example, project manager, sponsor, functional experts, technical experts, database administrators, change management and business process improvement experts. If you do not have the required resources in-house, you may be wise to look externally to one or more consulting organizations that specialize in project implementation to partner with you or lead the project. Young Goodman Brown - Losing Faith EssaySite Visits Optimally, visit organizations in your industry that have already implemented some of the products under consideration. Remember, however, that the organization you visit may not want or have time to communicate less than pleasant experiences. Try to ensure that the benefits will outweigh the costs. Short List Once initial responses are analyzed, develop a short list to consider further. Based on your case studies, request at least one scripted demonstration of the system. This is your chance to see the software and delve further into areas of concern or interest. Subsequent Information Gathering Based on your analysis to this point, you may request additional demonstrations from potential vendors. This provides you with an opportunity to ask additional questions regarding functionality, and will enable you to examine in greater depth questions regarding vendor support, future versions, etc. In addition, interviews with the sales team, technical support staff, and vendor executives may give you valuable insight to determine whether your company should embark on a long term relationship with a particular vendor. Contracting Prior to signing any agreements, make sure a lawyer, knowledgeable in software and ideally HR systems, reviews the contract. Consider incidental costs that may not be included in the initial costing, for example, training, support, or additional resources. Finally, remember that HRMS are complex systems. To derive the greatest value, implementation will take time, planning and energy. Set realistic goals. Your organizations ability to absorb change will directly drive and impact the overall implementation schedule. By taking the time to assess your organization, you can feel confident in answering the key question posed at the outset of this article: Does your organization really need an HRMS and is it ready to step up to the implementation?Recruiting and Staffing:The entire recruiting function is undergoing a virtualrevolution. Self-service systems are being installed on both the supply side forapplicants and the demand side for hiring managers, using the Internet not only tohelp provide the match, but also to help handle the hurdles along the way, such asapplicant testing and background screening. Companies can search thousands of resumes, internationally, either throughproprietary databases or those of vendors such as The Career Connect,CareerMosaic, CareerWeb, The Monster Board, or SkillsScape. Most resumes stillcome to companies on paper but whatever the media, paper, e-mail, the Web or fax,they can be scanned and re-formatted according to corporate specifications, andthen made available to the hiring manager or HR manager anywhere in a company,anywhere in the world. Improvements in optical character recognition have played an important part in thisnew capability, as have improvements in expert systems that providecategorizations and recognition of terms and rules. Systems can make inferencesabout skills and potential based on the words and phrases used in a resume. Newtechnology not only helps with the review of a large number of resumes, but it alsogets them to the right people quickly, using a variety of media and vendors. Thenext generation of recruiting software is incorporating skill-based questionsenabling the hiring company to pre-screen applicants. In ConclusionThe HR function, being one of the most data-intensive in any organization, is one ofthe leading beneficiaries and exploiters of these new achievements in technology. Now, HR professionals are more computer literate. They know how to use thetechnology to their advantage and to the overall benefit to the company. Utilizing thepower of new computers and software applications, notably the web, coupled withthe reengineering process, many organizations have started capturing self-servicedata for all personnel actions, such as new hires, salary changes and transfers,enrollment for training, as well as recruiting and staffing. All of this means more time for employees to do their job and it has meant valuableinformation for line management.

Tuesday, December 3, 2019

Us V. Causby Essays - Aviation Law, United States V. Causby

Us V. Causby United States V. Causby, 328 U.S. 256 (1946) In 1934 Lee Causby and his wife Tinie moved to a 2.8 acre plot of land just outside of Greensboro, North Carolina. Knowingly, they purchased the land, which was located only one-third of a mile from a municipal airport and began to raise chickens as a means of income. All was well until the spring of 1942 when the United States Army began to fly four-engine bombers over the property during all hours of the day and night. Due to the constant clamor numerous problems arose on the farmstead and as a result Lee and Tinie filed suit against the United States Army for the ?taking? of property defined under the Fifth Amendment. The Greensboro-Highpoint Municipal Airport was first established in 1928 eight miles from Greensboro, North Carolina. The airport was first commissioned to allow the take off and landing of small commercial flights and crop spraying planes. For approximately a decade and a half the Causby family, their chicken farm and the airport lived in harmony. This harmony was broken in April of 1942 when a lease was negotiated between the airport and the United State Army over the employment of the airport from May until June 1st of 1942. The lease also included provisions for renewal that would have lasted until 1967. It was with this contract in which the Causby's problems first began. According to the original complaint that was filed by the Causbys in the Court of Claims, the planes flown by the Army directly over their land caused the family to lose sleep, become constantly nervous and afraid. On top of this the noise and light created by the large aircraft frightened the chickens so much that they would fly into the sides of the buildings and barns, which would kill them instantly. Approximately six to ten chickens died in one day and a total of 150 chickens died altogether. Eventually production at the chicken farm fell off and the property became devaluated. After the courts examined the situation, the Court of Claims granted an easement of $2,000 for property damage. According to the findings of the Court of Claims, the Causby's home was 2,275 feet from the runway and the barn was only 2,220 feet away. Also due to the fact that the angle in which the planes took off, they flew directly over both the house and the barn. On April 1, 1946 the Supreme Court granted the petition of writ of certiorari to the Court of Claims even though Mr. Justice Jackson took no part in the decision. Only a month later, on May 1st, the case was brought before the Supreme Court of the United States of America by Mr. Walter J. Cummings of Washington D.C. representing the petitioner. For the respondents, the Causbys, Mr. William E. Comer of Greensboro, NC was in attendance. Once again Mr. Justice Jackson did not take part in the trial. Mr. Justice Douglas wrote the opinion of the court and upheld that decision should be reversed and remanded so that the findings of the Court of Claims are in conformity to the decision of the Supreme Court. This was due to the fact that the Army bombers and planes were flying so low, approximately sixty-seven feet above the house and sixty-three feet above the barn, and that the lease that was contracted between the United States and the Greensboro airport could not properly be determined whether it was a temporary or permanent in nature. Also the court was not satisfied with the findings of the Court of Claims so they ordered them to recheck all items dealing with the complaint and to specify more details in their findings. He also found that the due to the extreme amount of disruption caused by the United States' planes that there was hindrance to the ?enjoyment of property? which the Causbys were granted through the United States constitution. According to laws set up by the Civil Aeronautics Authority (CAA), at eighty-three feet above ground level it was declared that this altitude would be free airspace. The CAA declared all space that was above the reserved eighty-three feet to be public airspace. Therefore noise and other